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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Best Place for Code to Repeat Input Values... 2

Status
Not open for further replies.

deduct

Programmer
Jul 5, 2002
78
0
0
US
In order to Carry the values of certain fields from the current record into the next new record I want to insert this code into an event of my FORM:

fld_1.DefaultValue = "'" & fld_1.Value & "'"
fld_2.DefaultValue = "'" & fld_2.Value & "'"
fld_3.DefaultValue = "'" & fld_3.Value & "'"

Now, which event would be the best - BeforeUpdate, AfterUpdate, etc.? I have one book that suggests BeforeUpdate, and a Website that suggests AfterUpdate, and another Website that suggests putting it in a command button to conditionally execute it.

Also, can you think of any pitfalls to using this method to repeat field values?

Karl
 
I personally would attach it to a Command Button that would also contain the code for generating your New Record.

I do see one potential problem with what you're doing. Your user fills out the form, then hits New Record, and all of the fields remain exactly the same. How does your user know that they are in fact on a New Record, and not overwriting the one they just created?
 
To answer your question, Alien, these three are not all of the fields being input. Thus, the user will know it is a new record because there will be other blank fields still needing data.

I certainly understand the logic behind adding the code to a command button, but I would like this to me basically automatic.

Karl
 
Any other opinions, code change recommendations?

I would like this to be an automatic repeat of these specific fields (but they are not the only fields being input - just these three I want repeated).

I've thought about this some more, and perhaps I could even, when adding records, get the values from the last record input (whenever that happened to be) and set these three field's default value. As it is, the first new record of the session has either no default value, or the default value coded into the properties of each field. Is there a good way to accomplish this?

Karl
 
Try it in the On Current Event of the form but you will have to verify, FIRST, that the user has moved to a new record before you run the code or you will be overwriting older records.

My opinion is the same as the previous post. Using a command button verifys that the user wants to add a record and forces them to do so. Of course if you are not allowing editing and adding on the same form you would not have the problem. And it also depends on how savy your users are using Access.

Hope this helps.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top