Hi there,
I'm trying to use a Dlookup to fill a textbox on a form with the users name.
I've captured the username by using Environ("userna me") when the form loads and dumped that into a textbox.
I then want to Dlookup to relate the username to the staff list (a linked table) and bring back the persons name.
It sounds like it should be easy to do but I must be making a silly error but I can't see it. The code I'm using is:
Where:
TxtSubmitter is the text box I want the name returned to.
Consultant is the field in the table containing the values to be returned (i.e. Name).
TblLocalStaffLi st is the table containing the usernames and name.
Personnel Number is the field in the table to be checked,
and forms![Form1]!TxtUsername is the text box containing the username (that needs to be related to the table field "Personnel number".
I'm sure it's something simple and I've tried to be as complete as possible with the code and explinations but any questions just let me know and i'll do my best to clarify.
Thanks for your help.
I'm trying to use a Dlookup to fill a textbox on a form with the users name.
I've captured the username by using Environ("userna me") when the form loads and dumped that into a textbox.
I then want to Dlookup to relate the username to the staff list (a linked table) and bring back the persons name.
It sounds like it should be easy to do but I must be making a silly error but I can't see it. The code I'm using is:
Code:
Me.TxtSubmitter.Value = Dlookup("[Consultant]","TblLocalStaffList","[Personnel Number]"=forms![Form1]!TxtUsername")
TxtSubmitter is the text box I want the name returned to.
Consultant is the field in the table containing the values to be returned (i.e. Name).
TblLocalStaffLi st is the table containing the usernames and name.
Personnel Number is the field in the table to be checked,
and forms![Form1]!TxtUsername is the text box containing the username (that needs to be related to the table field "Personnel number".
I'm sure it's something simple and I've tried to be as complete as possible with the code and explinations but any questions just let me know and i'll do my best to clarify.
Thanks for your help.
Comment