Code to look up details

  • Thread starter Thread starter Simon
  • Start date Start date
S

Simon

On load of a form i have a txtUser field

Usally this field is Empty when frmOrder is open, if its Empty i
want
code to dispaly the UserID from this form[Forms]![frmMainMenu]!
[txtUserID]


If there is is already a number in txtUser, i do not want any numbers
to be changed and just left the same


Can any one point me in the right way for code?


Thanks
 
Simon said:
On load of a form i have a txtUser field

Usally this field is Empty when frmOrder is open, if its Empty i
want
code to dispaly the UserID from this form[Forms]![frmMainMenu]!
[txtUserID]


If there is is already a number in txtUser, i do not want any numbers
to be changed and just left the same


Can any one point me in the right way for code?

I don't feel I have enough information to say for sure what is the best way
to set this up, but the following code may be what you want:

If IsNull(Me!txtUser) Then
If CurrentProject.AllForms("frmMainMenu").IsLoaded Then
Me!txtUser = Forms!frmMainMenu!txtUserID
End If
End If
 
You can use the Default Value property of the txtUser textbox control on
frmOrder
It should look like:
=Forms!frmMainMenu!txtUserID

Now, one problem is you will get an error if frmMainMenu is not loaded

If you are not familiar with the Default Value property, it does exactly as
you describe. For new records or existing records where there is th userid,
it will populate the control with the indicated value. If the record has a
value, it will not affect that record.
 
Back
Top