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

Save last value in bound textbox to be used for subsequent records?

Status
Not open for further replies.

diddydustin

Programmer
Jul 30, 2002
181
US
Hey guys,

I have a simple form that interfaces a table with the following fields:

License, Vehicle_Make, Vehicle_Type, Vehicle_Color, Time, Direction, Vehicle_Markings, Misc, Location

The user enters data in each field and then proceeds to the next record to do the same. I would like for the LAST ENTERED Time and Location value to always stay consistent, so the user does not have to retype these values in.

Right now my method isn't working. On the AfterUpdate events of both of these bound textboxes, I have the value of two unbound textboxes, HiddenTime and HiddenLocation, being set. And then the Default value of Time and Location is set to [HiddenTime] and [HiddenLocation]. My logic would be that since these unbound textboxes held the last value, new records would always 'default' to the value in these boxes and they wouldn't have to enter this data. However, some funky stuff is happening! Sometimes the values default to the correct Time and Location, other times they don't. Sometimes they appear in there but when the user presses a key to enter data for any record the values in Time and Location are getting erased. Basically, I want to come up with another solution besides this cheap "work around" to do what I'm trying to do.

Any help would be appreciated! Hope all this makes sense--

diddydustin
 
How are ya diddydustin . . .

Have a look at the [blue]Default Value[/blue] property of a textbox . . .

Calvin.gif
See Ya! . . . . . .
 
Yes, I know that, but how can I set the Default Property of a textbox via VBA, and not manually through Access?

D
 
The Default Property is not a static value and changes dynamically with each input from the user.

D
 
OK diddydustin . . .

Try this in the forms [blue]BeforeUpdate[/blue] event:
Code:
[blue]   If Me.NewRecord Then
      If Trim(Me!Time & "") = "" Then
         Me!Time.DefaultValue = ""
      Else
         Me!Time.DefaultValue = "#" & Me!Time & "#"
      End If
      
      Me!Location.DefaultValue = """" & Me!Location & """"
   End If[/blue]

Calvin.gif
See Ya! . . . . . .
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top