Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Easily Updated Default Value

Status
Not open for further replies.

kvest

Technical User
Jan 10, 2005
62
US
Hello,
I am working on a database where I need to insert a default value (number) into a few fields upon creation. This is easy enough to do by using the default value field, but this number will likely need to be updated in the future due to changes in fees. I would not expect this to change more than once every couple of years so I doubt I will still be at this location when the need arises.

Is there some means to create lookup table that works similar to the default value function by automaticly entering in the last value in the table? I have created a lookup field with amounts and corresponding change dates, but havent been able to figure this out.

If this is possible to do so that a selected user can change this fee without having to modify the table?

Thanks in advance
 
The user could use the keyboard strokes ctrl apostrophe to copy the last value entered into the field (from the previous record).

If you are entering data into a form (which you should be doing), in the form's OnCurrent event you could write code to determine the "last" value of the field and plunk it into that field. That would meaning taking the default value out of the table field. It could be something like this:

If Isnull(Me.ControlName) then Me.ControlName = Dlast("FieldNameInTable","TableName")


Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244. Basics at
 

Create your lookup table with an autonumber ID so they stay in the right order, and with the field that contains the value to be used.

Create a form to update that table, so the user can just add the newest default value.

on the form that will be using that table to find the default value, set it up so the user can only enter a new record via a command button.

On the command button, put the following:

DoCmd.GoToRecord , , acNewRec
Me.field = DLast("DefaultValue", "table1")

 
Thank both of very much. I will give it a try.
 
It works great.!!!! Thanks a ton. One follow up question though...

I have four of these fees that may change infrequently. I assume that I will have to create a lookup table for each of them since I cant insure that all the fees will change at the same time (or even at all).

 
I created a query that sorts this information and returns the result and referenced that in the code vs. the lookup table. It works great...thanks for helping and teaching me several things.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top