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!

DLOOKUP on forms 1

Status
Not open for further replies.

slames

Technical User
Nov 5, 2002
211
GB
Hi
I am trying to use form text box values as the criteria for the dlookup, but am getting an #error! showing.
Is it possible to do this and if so do I have a syntax error in this:

=DLookUp('" & [Forms]![FRMEDIT]![MAGID] & "','" & [Forms]![FRMEDIT]![MAGTable] & "','" & [Forms]![FRMEDIT]![MAGISSUE] & "' & " = " & '" & [Forms]![FRMEDIT]![FROM_ISSUE] &"')

Thanks in advance

Steph
 
Hi,

You have way too many quotes in there :)

Same form:
Code:
= DLookup(Me.txtField, Me.txtTable, Me.txtCriteria & " = " & Me.txtClause)

Sub form
Code:
= DLookup(Forms!MainForm!SubForm.txtField, Forms!MainForm!SubForm.txtTable, Forms!MainForm!SubForm.txtCriteria & " = " & Forms!MainForm!SubForm.txtClause)

Hope that helps
Sim



----------------------------------------
I was once asked if I was ignorant or just apathetic. I said, "I don't know, and I don't care."
----------------------------------------
 
Thanks for your reply - that has got me half of the way! Although I am still having trouble with the criteria part of dlookup.
I couldn't use me. as it the object did not contain the automation object me.

This is what I thought it should be but I can't get the criteria bit to work:
=DLookUp(Forms!frmEdit!MagID,Forms!frmEdit!magTable,Forms!frmEdit!issue=forms!frmEdit!fromissue)

It works this far:

=DLookUp(Forms!frmEdit!MagID,Forms!frmEdit!magTable,"medIssue ='2-4'")

The value of the text box issue is 2-4 in this instance. It is a text value.

Can anyone help me with this?

Thanks

Steph
 
Ello,

Change your criteria to:

Forms!frmEdit!issue & " = " & forms!frmEdit!fromissue

or if needs be:

Forms!frmEdit!issue & " = '" & forms!frmEdit!fromissue & "'"

If you need the exrea set of quotes.

That should fix the problem you were having.
Sim

----------------------------------------
I was once asked if I was ignorant or just apathetic. I said, "I don't know, and I don't care."
----------------------------------------
 
Fantastic, working fine now.
Thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top