DlookUp

  • Thread starter Thread starter Julia82
  • Start date Start date
J

Julia82

Hello,

I have:
Me.User.Value = DLookup("Access", "UserT", "UID= " &Name)

where:
User = Text Box
Access = Field 3 from Table "UserT" (text)
UID = Field 1 = Autonumber (number)
Name = Field 2 from Table "UserT" (text)

I Want:

To lookup for the Access of the Name in the UserT Table.
I want to veryfi What access has the username in the same table by the id of
the name in the same table. Hope this makes sense.

I have two text boxes. When there is text in that textbox, I want the text
to be verifyed in the table UserT and to read from Access field and display
value.

What do I do wrong? Thanks!
 
I suggest you use a combo instead of a textbox.
The combo's row source would be a query with UID and Name for the 2 columns.
After user chooses their name from the combo, you can do the DLookup.

Me.User = DLookup("Access", "UserT", "UID= " & [NameOfCombo])

The above code will show the value of "Access" in the second textbox.

I also recommend using Nz in case the dlookup can't find a matching value.

Me.User = Nz(DLookup("Access", "UserT", "UID= " & [NameOfCombo]),"no
access")



Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia
 
Thanks for your reply Janette,

But if I don't want to use a combo instead of textbox, there is a way to get
this done?

Thank You!

Jeanette Cunningham said:
I suggest you use a combo instead of a textbox.
The combo's row source would be a query with UID and Name for the 2 columns.
After user chooses their name from the combo, you can do the DLookup.

Me.User = DLookup("Access", "UserT", "UID= " & [NameOfCombo])

The above code will show the value of "Access" in the second textbox.

I also recommend using Nz in case the dlookup can't find a matching value.

Me.User = Nz(DLookup("Access", "UserT", "UID= " & [NameOfCombo]),"no
access")



Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia

Julia82 said:
Hello,

I have:
Me.User.Value = DLookup("Access", "UserT", "UID= " &Name)

where:
User = Text Box
Access = Field 3 from Table "UserT" (text)
UID = Field 1 = Autonumber (number)
Name = Field 2 from Table "UserT" (text)

I Want:

To lookup for the Access of the Name in the UserT Table.
I want to veryfi What access has the username in the same table by the id
of
the name in the same table. Hope this makes sense.

I have two text boxes. When there is text in that textbox, I want the text
to be verifyed in the table UserT and to read from Access field and
display
value.

What do I do wrong? Thanks!


.
 
Sorry,

I ment if I want to use a textbox instead of combo like you said, this can
be done?
 
Do you want the user to type their name into the textbox?
If Yes, then change the DLookup like this

Me.User = Nz(DLookup("Access", "UserT", "[NameOfNameField]= """ &
[NameOfNameControl] & """"),"no
access")

Note: replace field and control names to match those on your form and table.

Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia
 
Thanks for your time.

I had to find out that there are 3 types of expressions. One for the date,
one if it's a number and another one if it's a text, how I had.

Now works perfectly.

Jeanette Cunningham said:
Do you want the user to type their name into the textbox?
If Yes, then change the DLookup like this

Me.User = Nz(DLookup("Access", "UserT", "[NameOfNameField]= """ &
[NameOfNameControl] & """"),"no
access")

Note: replace field and control names to match those on your form and table.

Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia


Julia82 said:
Sorry,

I ment if I want to use a textbox instead of combo like you said, this can
be done?


.
 
Back
Top