dlookup works on one field but not the other

E

efandango

I have two fields that I want to fill with data. The first field [Postcode]
works just fine. But the 2nd field; [txt_Run_waypoint_ID_From] just gives a
blank; no error messages, just blank.

The field [txt_Run_waypoint_ID_From] is a text field, the lookup field,
[StreetNameID] is an autonumber field.


I have tried different syntax in the code, but nothing seems to work. What
am I doing wrong?



My code:

Private Sub Road_Name_From_AfterUpdate()

Me.txt_Run_waypoint_ID_From = DLookup("[StreetNameID]", "tbl_Street_Names",
"[Run_waypoint_ID_From] = '" & Me.Road_Name_From.Column(0) & "'")

Me.Postcode_From = DLookup("[PostCode]", "tbl_Street_Names", "[StreetNameID]
=" & Road_Name_From.Column(0))

Exit_Road_Name_From_AfterUpdate:


End Sub
 
K

Klatuu

Me.txt_Run_waypoint_ID_From = DLookup("[StreetNameID]", "tbl_Street_Names",
"[Run_waypoint_ID_From] = '" & Me.Road_Name_From.Column(0) & "'")

Me.Postcode_From = DLookup("[PostCode]", "tbl_Street_Names", "[StreetNameID]
=" & Road_Name_From.Column(0))

Are you expecting [Run_waypoint_ID_From] and [StreetNameID] to contain the
same data? Are you sure you want to use Column(0) for both lookups?
 
J

Jeff Boyce

What data types are involved in the looked-up fields?

Regards

Jeff Boyce
Microsoft Office/Access MVP
 
E

efandango

Guys, thanks for your quick response.

but I have since recolved the problem. with this:
Me.txt_Run_waypoint_ID_From = DLookup("[StreetNameID]", "tbl_Street_Names",
"[StreetNameID] =" & Road_Name_From.Column(0))


All is well now.

Jeff Boyce said:
What data types are involved in the looked-up fields?

Regards

Jeff Boyce
Microsoft Office/Access MVP

efandango said:
I have two fields that I want to fill with data. The first field [Postcode]
works just fine. But the 2nd field; [txt_Run_waypoint_ID_From] just gives
a
blank; no error messages, just blank.

The field [txt_Run_waypoint_ID_From] is a text field, the lookup field,
[StreetNameID] is an autonumber field.


I have tried different syntax in the code, but nothing seems to work. What
am I doing wrong?



My code:

Private Sub Road_Name_From_AfterUpdate()

Me.txt_Run_waypoint_ID_From = DLookup("[StreetNameID]",
"tbl_Street_Names",
"[Run_waypoint_ID_From] = '" & Me.Road_Name_From.Column(0) & "'")

Me.Postcode_From = DLookup("[PostCode]", "tbl_Street_Names",
"[StreetNameID]
=" & Road_Name_From.Column(0))

Exit_Road_Name_From_AfterUpdate:


End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top