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

Repeat last record in access 2000

Status
Not open for further replies.

rmyslik

IS-IT--Management
Aug 2, 2001
33
US
I haven't used or created a new database in a while and am making a data base for fuel. The thing is I want the employee and date (two fields) to stay when you go to a new record so entering a week or a month of fuel could be easier. I am sure there is some silly answer so PLEASE help me! Thank you
 
How are ya rmyslik . . . .

In the forms [blue]AfterUpdate[/blue] Event, change the [blue]DefaultValue[/blue] for the specific controls to the data in the control.

[blue]Me!ControlName.DefaultValue=Me!ControlName[/blue]

Calvin.gif
See Ya! . . . . . .
 
In the Form's BeforeUpdate event, set the DefaultValue properties of these controls to their current values. Note that the DefaultValue property must be set to a string, so when setting the date, for example, instead of using
txtDate.Defaultvalue = txtDate
you would use something like
txtDate.DefaultValue = "#" & Format$(txtDate, "short date") & "#"

Rick Sprague
Want the best answers? See faq181-2886
To write a program from scratch, first create the universe. - Paraphrased from Albert Einstein
 
OK I can do that. What I cannot get is what is
Me!ControlName.DefaultValue=Me!ControlName Referring to?

I have tables of service and the field employee. Are they to be inserted there? Sorry for being thick but it has been a while and I hope it will all click back!!
 
rmyslik . . . . .

First [blue]RickSpr[/blue] is right. The [blue]BeforeUpdate[/blue] is better suited for this purpose.

[blue]ControlName[/blue] is the name of the comtrol you want to carry forward (in your case the name of the two fields . . . one line for each). You substitute [blue]ControlName[/blue] with the actual name.

Calvin.gif
See Ya! . . . . . .
 
Another short note, when having regional settings differing from US date format, you might need to format the date to a format, for instance like this:

[tt]Me!txtDate.DefaultValue = "#" & Format$(Me!txtDate, "yyyy-mm-dd") & "#"[/tt]

This is performed in code (VBA), in the Forms Before Update event procedure, for the controls you need to carry over values for.

Roy-Vidar
 
OK, I'm trying to do this also. I used to put in a module into the form, and then add an unbound text box with a list of the controls I wanted to carry data forward to. But I can't get this to work now.

But I can't get the befordataupdate event procedure to work either. Maybe I'm being thick.

My control is a text box called "Project Name" So I put in the Form's Beforedataupdate eventprocedure:

Me![Project Name].DefaultValue = Me![Project Name]

And nothing happens. What's my problem. Thanks.
 
Form's Beforedataupdate eventprocedure
???
Should be the BeforeUpdate event procedure

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top