Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem using Dlookup 1

Status
Not open for further replies.

MA04

Technical User
Dec 21, 2004
162
GB
Hi guys,

I have one main form: ma_search2 which is unbound. Which has an unbound textbox: EnterPostcode, which is for user entry. When the user enters a post code (string), i want it to filter a table called: ma_dbo_uk, with field: POSTCODE. Now i have a command button which opens up a 2nd form: prmf(unbound), which has one textbox: txt_prmf which i hope to display a field: PRMF (also unbound) from same table, with the record entered by the user in textbox: EnterPostcode in the first form.

This is what i have so far on the on open property of the 2nd form:
Code:
If IsNull(Forms![ma_search2]![EnterPostcode]) Then
MsgBox "You did not enter anything in the first text box"
Exit Sub
Else
Me.txt_prmf = DLookup("dbo_UK_homes.PRMF", "dbo_UK_homes", "dbo_UK_homes.POSTCODE='" & Forms![ma_search2]![EnterPostcode] = "'")
End If

The code does not give any errors but does not display anything in textbox, does not display field prmf, from record filtered by textbox: EnterPostcode.

Any help appreciated, thanks in advance,
M-.
 
I'm not sure how much of a difference this will make, I don't have Access running at the moment, but the second parameter for DLookup is the table name, so you don't need it in the other parameters.

DLookup("PRMF", "dbo_UK_homes", "POSTCODE='" & Forms![ma_search2]![EnterPostcode] = "'")
 
Thanks for the reply earthandfire but did try that before but get same result, if the code is correct the problem may lay in some property setting of the form or textbox, not sure though.

M-.
 
I can't check this for the moment, but you may need to use the value property as the text box is unbound.
 
I think this should be correct
Code:
DLookup("PRMF", "dbo_UK_homes", "POSTCODE='" & Forms![ma_search2]![EnterPostcode] & "'")
or
Code:
DLookup("PRMF", "dbo_UK_homes", "POSTCODE='" & Forms![ma_search2]![EnterPostcode])

________________________________________
Zameer Abdulla
Visit Me
The best thing to spend on your child is your time.
 
Thanks (Jazakallah) Zameer,

The "&" made all the difference did not get response any other way.
Code:
DLookup("PRMF", "dbo_UK_homes", "POSTCODE='" & Forms![ma_search2]![EnterPostcode] [b][COLOR=blue]&[/color blue][/b] "'")
M-.
 
You welcome

________________________________________
Zameer Abdulla
Visit Me
The best thing to spend on your child is your time.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top