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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Can We use DLookUp fucntion in the control source property of text box 1

Status
Not open for further replies.

Jawad77

Programmer
Dec 23, 2004
41
US
I have a text box in my main form. I like to use DLookUp function as its control source to populate it with a single numeric value called CF.

The reason I like to use DLookup function because I don't want the table containing CF to be opened when I am on my main form. This is becasue I am referencing the CF table in one of my modules that also runs only when my main form is open. So If my CF table is open while I am on my main form, the module gives me error.

I tried using this but it doesn't work

DLookup("[CF]","[CFTable]","[PG] = Forms![MainForm]![lbx_PG]" And "[DC] = Forms![MainForm]![lbx_DC]")


Forms![MainForm]![lbx_PG] will return a numeric value
Forms![MainForm]![lbx_DC] will return a numeric value

I also tried using this but it doesn't work either:

DLookup("[CF]","[CFTable]","[PG] =" & Forms![MainForm]![lbx_PG] & "And" & "[DC] =" & Forms![MainForm]![lbx_DC])

Any ideas/help will be highly appreciated. Thanks

Jay

 
=DLookup("[CF]","[CFTable]","[PG] = " & Forms![MainForm]![lbx_PG]& " And "[DC] = " & Forms![MainForm]![lbx_DC] & ")
 
This should do it.

=DLookup("[CF]","[CFTable]","[PG] = " & [Forms]![MainForm]![lbx_PG] & " AND [DC] = " & [Forms]![MainForm]![lbx_DC])

I am what I am based on the decisions I have made.

DoubleD [bigcheeks]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top