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!

Keep field value when starting a new record. Like a temp default

Status
Not open for further replies.

pbrown2

Technical User
Jun 23, 2003
322
US
Currently I have set up a switchboard that when an area is selected that area is automatically filled into the field "Plant". However,when the user clicks on the button to go to the next aval blank record the field "Plant" goes blank. Below is the code on the "Go to next record" button:

Private Sub Command36_Click()
If IsNull(Me![Project Classification]) Then
MsgBox ("Project Classification is Missing, Please Complete")
[Project Classification].SetFocus
Else
If IsNull(Me![Notes]) Then
MsgBox ("Project Description is Needed, Please Complete")
[Notes].SetFocus
Else
Text12.SetFocus
Text14.SetFocus
DoCmd.GoToRecord , , acNewRec
[Project Classification].SetFocus
End If
End If
End Sub

Is there away to have this code also say to keep the value that is currently in [Plant]? Basically set a default for [Plant] until the form is exited. So that if the user goes back to the switchboard and chooses a different area, the new area will be used.

Any suggestions?

Thank you for any and all help,

PBrown
 
Probably the simplest way to do this is to save the value of your guy in an unbound text variable before you save the record. When you go to a new record, push this value in to the appropriate field in your new guy. Kinda like this:

SaveRecord:
txtPlant = me!Plant

AddNewRecord:
...gotoRecord, acNew...
me!Plant = txtPlant
...

Hopefully you'll know how to fill in the "..." stuff ... :)

Jim


Don't be sexist - Broads hate that.
Another free Access forum:
More Access help stuff at
 
I know this is much too simplistic but sometimes the best are the easiest... Plus I don't code much - have to find a way to do things within the system itself. To repeat a field from the last form use &quot;<ctrl> ' &quot; (of course without the quotes).
 
This next step is somewhat off the main subject but is relevant....
In one of the forms now I need to tell the form only display certain records according to which button is pressed.
I have tried:

Dim strWhere As String
strWhere = strWhere & &quot; and [Plant] = 'Cars'&quot;
DoCmd.OpenForm &quot;Entry Management&quot;, , strWhere


But the form is displaying all the records (Cars/Trucks/SUVs). What am I missing in the code to make it only display the records where [Plant] = &quot;Cars&quot;?

Thank you for any and all help,

PBrown
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top