I have a table with three fields in each record: managed net outstandings, held net outstandings and Data Date. A form named “update outstandings” is used to populate these fields in the underlying table. What I would like to do is have “held net outstandings” default to the value of “managed net outstandings” as the data is entered in the form. I’d also like the “data date” field values to default to the first “data date” entry made, since all the records will be updated at the same time. I’ve tried playing with the “after update” control in “managed net outstandings” and “data date”, but I can’t seem to get it to work correctly (compile error, can’t find project or library). Any help would be greatly appreciated. Thanks
![]() |
There are isolated problems with current patches, but they are well-known and documented on this site. |
SIGN IN | Not a member? | REGISTER | PLUS MEMBERSHIP |
-
Field default value in a form (2000)
Home » Forums » AskWoody support » Productivity software by function » MS Access and database help » Field default value in a form (2000)
- This topic has 23 replies, 3 voices, and was last updated 22 years, 1 month ago.
Viewing 0 reply threadsAuthorReplies-
WSHansV
AskWoody Lounger -
WSzbrett
AskWoody LoungerApril 9, 2003 at 2:43 pm #667454I’m just learning to code in Access, so I apologize if this is way off…
Anyway, the first thing I tried to tackle was the default for the “Data date” field.
Private Sub Last_Update_Date_AfterUpdate() <– This is highlighted when the compile error box pops up.
Update_Outstandings!Data_Date.DefaultValue = """" & Update_Outstandings!Data_Date.Value & """"
End Sub
I'm not sure where to begin to get the "net outstandings" to default to the "managed outstandings."
-
WSHansV
AskWoody LoungerApril 9, 2003 at 2:52 pm #667456In the first place, remove Update_Outstandings! (twice). If you needed to refer to the form explicitly (which you don’t, since you’re on that form), it should have been Forms!Update_Outstandings!…, but you can omit it here.
See if the error goes away.
If not, what is Last_Update_Date? The line after it mentions Data_Date, so shouldn’t it be Data_Date? See what happens if youchange Last_Update_Date_afterUpdate to Data_Date_AfterUpdate.
Note for the future: you have used names for fields, controls and form with spaces in them. Although this is allowed, it is not to be recommended. It makes coding more difficult; as you can sse here, Access has replaced spaces by underscores. You can always set the caption property of fields to make labels display user-friendly text.
-
WSzbrett
AskWoody LoungerApril 9, 2003 at 3:22 pm #667464Yes, I realized I shouldn’t be using spaces long after I should have…
Anyway, I changed it to:
Private Sub Last_Update_Date_AfterUpdate()
Last_Update_Date.DefaultValue = “””” & Last_Update_Date.Value & “”””
End Sub
It now runs without error, but nothing happens. Shouldn’t this populate the remaining Last_Update_Date fields in the table with the same value?
-
WSHansV
AskWoody LoungerApril 9, 2003 at 3:56 pm #667473Open your form in design view.
Select the “Last Update Date” control.
Activate the Properties window, Events tab
Click in the AfterUpdate event.
If it hasn’t been selected, select Event Procedure.
Click the builder button (the three dots …)
You should be taken to your procedure.
Switch back to Access, and save the form.
Test if AfterUpdate now works. -
WSzbrett
AskWoody Lounger -
WSHansV
AskWoody LoungerApril 9, 2003 at 6:22 pm #667515Try the following:
Repeat the steps from my previous reply until you are in the Visual Basic Editor (or return there if it is still open).
Click in the margin to the left of the line Private Sub Last_Update_Date_AfterUpdate()
The line should be highlighted in brown, and should be marked by a brown bullet in the left margin. This is called a breakpoint.
Switch back to Access, and open the form. Change the date and press Tab or Enter.
You should be taken to the Visual Basic Editor, with execution of the event procedure paused at the breakpoint.
If that doesn’t happen, something must have gone wrong when you followed the steps from my previous post.
If it does, single step through the code by pressing F8 repeatedly.
Does the highlighted yellow line move down, and disappear when you’ve come to the end of the procedure? -
WSzbrett
AskWoody Lounger -
WSHansV
AskWoody LoungerApril 9, 2003 at 7:02 pm #667525I’m afraid I don’t understand why it doesn’t work. Let’s try something different.
In Microsoft Knowledge Base Article 210236, Microsoft describes a method of filling one or more fields in a new record with values from the previous record. You can also download a sample database with a form that demonstrates this method. I hope that you can apply it to your database.
I hesitate to ask it, but if you wish, you can attach a stripped down, sanitized, compacted and zipped version of your database to a post. That way, other Loungers can try to pin down the problem. Remove everything that is not needed to demonstrate the problem. The zip file should be less than 100 KB.
-
WSzbrett
AskWoody Lounger -
WSHansV
AskWoody LoungerApril 9, 2003 at 8:47 pm #667550It works! But what in heavens name is your purpose? The form doesn’t allow adding a new record, so you’ll never see the effect of setting the default value!
I have set Allow Additions to Yes, and added code to set the default value (and optionally the value in the current record) of Held Net Outstandings to the value of Managed Net Outstandings.
-
WSzbrett
AskWoody LoungerApril 10, 2003 at 1:57 am #667614Trust me, there is another form for this table that allows for records (vendors and vendor numbers) to be added.
This form is for only updating the outstandings $$. There is also an append query that moves the old outstanding values to a different table when you open this form.
Anyway, I really appreciate the help. I’ll let you know tomorrow if I was able to get it to work.
Regards,
Brett
-
WSzbrett
AskWoody LoungerApril 10, 2003 at 1:18 pm #667729Good news and bad news. Good news: The net outstanding field defaults to the managed outstanding without a problem. Bad news: Bad communication on my behalf. What I’m trying to do is when the date is changed in the first record, I want it to change the date field for the rest of the existing records. For example, all of the records have a date of 4/2003. When I update the first record to 5/2003, I want the rest of the records to default to that value as well. Is this even possible?
Thanks for all of your help.
Brett
-
WScharlotte
AskWoody Lounger -
WSzbrett
AskWoody Lounger -
WSHansV
AskWoody LoungerApril 10, 2003 at 2:59 pm #667763Something like this will change the date when it is changed in any record, not just the first one:
Private Sub Last_Update_Date_AfterUpdate()
CurrentDb.Execute “UPDATE Vendors SET [Data Date] = #” & Format(Last_Update_Date, “mm/dd/yyyy”) & “# ”
End SubBut, as you will find, this causes a conflict. You should only set the date for other records. For this, you need a unique key, for instance an AutoNumber field VendorID. Then you can use
CurrentDb.Execute “UPDATE Vendors SET [Data Date] = #” & Format(Last_Update_Date, “mm/dd/yyyy”) & “# ” & _
” WHERE VendorID ” & VendorID -
WSzbrett
AskWoody LoungerApril 10, 2003 at 4:11 pm #667776The vendor_number is a unique field, so I tried this:
CurrentDb.Execute “UPDATE Vendor_Number SET [Data Date] = #” & Format(Last_Update_Date, “mm/dd/yyyy”) & “# ” & _
” WHERE Vendor_Number ” & Vendor_NumberOf course it failed since I’ve got something named incorrectly. I get “can find project or library” error and it highlights “Format” no matter what I try. So where and how do I put the proper name in? I
-
WSHansV
AskWoody Lounger -
WSzbrett
AskWoody LoungerApril 10, 2003 at 6:15 pm #667787I changed the code to read:
CurrentDb.Execute “UPDATE Vendors SET [Data Date] = #” & Format(Last_Update_Date, “mm/dd/yyyy”) & “# ” & _
” WHERE Vendor_Number ” & Vendor_NumberBut now I get the error: runtime error 3061 too few parameters. expected 2. Argh. I’m sorry this is so painful.
-
WSHansV
AskWoody Lounger -
WSzbrett
AskWoody LoungerApril 10, 2003 at 7:16 pm #667799I tried:
CurrentDb.Execute “UPDATE Vendors SET [Data Date] = #” & Format(Last_Update_Date, “mm/dd/yyyy”) & “# ” & _
” WHERE [Vendor Number] ” & [Vendor Number]and
CurrentDb.Execute “UPDATE Vendors SET [Data Date] = #” & Format(Last_Update_Date, “mm/dd/yyyy”) & “# ” & _
” WHERE [Vendor Number] ” & Vendor_NumberNow I get Runtime error 3061 too few parameters. Expected 1.
-
WSHansV
AskWoody LoungerApril 10, 2003 at 7:25 pm #667801Well, that’s one less than before, so you’re halfway there
On looking back at your database, I notice that Vendor Number is not a number, but text. (Long live consistency). Should have remembered that. That means that the value must be enclosed in quotes. Try
CurrentDb.Execute “UPDATE Vendors SET [Data Date] = #” & Format(Last_Update_Date, “mm/dd/yyyy”) & “# ” & _
” WHERE [Vendor Number] ” & Chr(34) & Vendor_Number & Chr(34)ASCII/ANSI character 34 is the double quote “.
-
WSzbrett
AskWoody Lounger
-
-
-
-
Viewing 0 reply threads -

Plus Membership
Donations from Plus members keep this site going. You can identify the people who support AskWoody by the Plus badge on their avatars.
AskWoody Plus members not only get access to all of the contents of this site -- including Susan Bradley's frequently updated Patch Watch listing -- they also receive weekly AskWoody Plus Newsletters (formerly Windows Secrets Newsletter) and AskWoody Plus Alerts, emails when there are important breaking developments.
Get Plus!
Welcome to our unique respite from the madness.
It's easy to post questions about Windows 11, Windows 10, Win8.1, Win7, Surface, Office, or browse through our Forums. Post anonymously or register for greater privileges. Keep it civil, please: Decorous Lounge rules strictly enforced. Questions? Contact Customer Support.
Search Newsletters
Search Forums
View the Forum
Search for Topics
Recent Topics
-
Firefox Red Panda Fun Stuff
by
Lars220
4 hours, 21 minutes ago -
How start headers and page numbers on page 3?
by
Davidhs
7 hours, 54 minutes ago -
Attack on LexisNexis Risk Solutions exposes data on 300k +
by
Nibbled To Death By Ducks
2 hours, 29 minutes ago -
Windows 11 Insider Preview build 26200.5622 released to DEV
by
joep517
16 hours, 34 minutes ago -
Windows 11 Insider Preview build 26120.4230 (24H2) released to BETA
by
joep517
16 hours, 36 minutes ago -
MS Excel 2019 Now Prompts to Back Up With OneDrive
by
lmacri
6 hours, 17 minutes ago -
Firefox 139
by
Charlie
7 minutes ago -
Who knows what?
by
Will Fastie
11 hours, 41 minutes ago -
My top ten underappreciated features in Office
by
Peter Deegan
17 hours, 20 minutes ago -
WAU Manager — It’s your computer, you are in charge!
by
Deanna McElveen
11 hours, 43 minutes ago -
Misbehaving devices
by
Susan Bradley
19 hours, 28 minutes ago -
.NET 8.0 Desktop Runtime (v8.0.16) – Windows x86 Installer
by
WSmeyerbos
1 day, 23 hours ago -
Neowin poll : What do you plan to do on Windows 10 EOS
by
Alex5723
1 hour, 41 minutes ago -
May 31, 2025—KB5062170 (OS Builds 22621.5415 and 22631.5415 Out-of-band
by
Alex5723
1 day, 21 hours ago -
Discover the Best AI Tools for Everything
by
Alex5723
21 hours, 2 minutes ago -
Edge Seems To Be Gaining Weight
by
bbearren
1 day, 12 hours ago -
Rufus is available from the MSFT Store
by
PL1
1 day, 20 hours ago -
Microsoft : Ending USB-C® Port Confusion
by
Alex5723
2 days, 23 hours ago -
KB5061768 update for Intel vPro processor
by
drmark
22 hours, 49 minutes ago -
Outlook 365 classic has exhausted all shared resources
by
drmark
21 hours, 32 minutes ago -
My Simple Word 2010 Macro Is Not Working
by
mbennett555
2 days, 18 hours ago -
Office gets current release
by
Susan Bradley
2 days, 21 hours ago -
FBI: Still Using One of These Old Routers? It’s Vulnerable to Hackers
by
Alex5723
4 days, 11 hours ago -
Windows AI Local Only no NPU required!
by
RetiredGeek
3 days, 19 hours ago -
Stop the OneDrive defaults
by
CWBillow
4 days, 12 hours ago -
Windows 11 Insider Preview build 27868 released to Canary
by
joep517
4 days, 22 hours ago -
X Suspends Encrypted DMs
by
Alex5723
5 days ago -
WSJ : My Robot and Me AI generated movie
by
Alex5723
5 days ago -
Botnet hacks 9,000+ ASUS routers to add persistent SSH backdoor
by
Alex5723
5 days, 1 hour ago -
OpenAI model sabotages shutdown code
by
Cybertooth
5 days, 1 hour ago
Recent blog posts
Key Links
S | M | T | W | T | F | S |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | 6 | 7 |
8 | 9 | 10 | 11 | 12 | 13 | 14 |
15 | 16 | 17 | 18 | 19 | 20 | 21 |
22 | 23 | 24 | 25 | 26 | 27 | 28 |
29 | 30 |
Want to Advertise in the free newsletter? How about a gift subscription in honor of a birthday? Send an email to sb@askwoody.com to ask how.
Mastodon profile for DefConPatch
Mastodon profile for AskWoody
Home • About • FAQ • Posts & Privacy • Forums • My Account
Register • Free Newsletter • Plus Membership • Gift Certificates • MS-DEFCON Alerts
Copyright ©2004-2025 by AskWoody Tech LLC. All Rights Reserved.