Lookup into a table - populate same field

papasmurfuo9

Registered User.
Local time
Yesterday, 21:35
Joined
May 28, 2014
Messages
69
Hi All
please could someone help with the below

i have a table holding a list of post codes, and their servicing depot EG -

ID Postcode Depot
1 AB10 Edinburgh
2 AB11 Edinburgh


then a form, which has a field for depot ( Fld_Depot )

what i would like is, when the user clicks on the field, a msg box prompts, asking for them to input a postcode

once the postcode is entered, it populates that field with the relevant depot from the table

many thanks
 
Simple answer would be to use a DLookup,
Code:
Private Sub getDepotButton_Click()
    Dim tmpStr As String
    tmpStr = InputBox("Please enter the PostCode")
    Me.Fld_Depot = Nz(DLookup("Depot", "tableName", " Postcode = '" & tmpStr & "'"), "N/A")
End Sub
on the other hand would it not be simple if you used a Combo box?
 
works perfect thank you

the ascetics of the form need it this way, thank u very much
 

Users who are viewing this thread

Back
Top Bottom