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

How do I store a value for reuse

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
I want to be able to enter a value into a field and have that value carried forward when I add a record. I want to be able to do this continually until I enter a new value into that field at which time the new value will be stored.
 
Just one way.

Dim a module level variable and in the OnOpen event intialize the value. Then, in the OnCurrent event set the value of the control. In the AfterUpdate event of the control reset the value of the variable. This maintains it current, kind of like a requery.

Steve King
 
Need to make sure you dim with the "Public" keyword.

Public varVariableName As Whatever

 
An alternative. Make "some" value the default value for the table/field. In the BeforeUpdate event of the form, check the IsDirty property of the textbox with the "carry forward" entry. If IsDirty is true, execute a routine which sets the DefaultValue to the new value of the textbox.


MichaelRed
redmsp@erols.com

There is never time to do it right but there is always time to do it over
 
Now I've run into another problem. Any time that I move to a different record (forwards or backwards), the field of the record that is current is automatically changed.

I'm fairly new to access programming. If anyone has any theories on what I may be doing wrong, please let me know.
 
Try this addition to your On Current event:
If IsNull([NameOfFieldYouWantToDumpYourValueInto]) then
Do what you've been doing to dump the value.
End If

We still don't know what the value is (text/number) so you might need to use:
If [NameOfFieldYouWantToDumpYourValueInto]="" then
Do what you've been doing to dump the value.
End If Gord
ghubbell@total.net
 
Ok, How bout If you want to pass a value back to a query. This value is used to run a comple of queries that are run if a check box is selected (or deselected)???
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top