Results 1 to 4 of 4
  1. #1
    Join Date
    Jul 2006
    Posts
    108

    Unanswered: Dlookup...it hates me

    Ok, occassionally a dlookup function will work the first time others i can never seem to figure out this is my current Dlookup expression that is in a textbox on a form.

    =DLookUp("txt_name","tbl_P_Vendors","[tbl_P_Vendors]![ID]=[num_venderID])

    where txt_name is a field in tbl_P_Vendors and num_venderID is a field in my table

    can anyone please sort out why its sending me the #name message?

  2. #2
    Join Date
    Nov 2004
    Location
    Norway
    Posts
    441
    If you look it up in the help files, you will probably find that the first argument, is supposed to be the field (in the table) which you're looking up. The second, is the name of the table, the third, is the criterion.

    I haven't seen naming conventions prefixing field names with txt, but ensure you're using the correct field name.

    For the criterion, since you have specified the table as second arguement, there is no need to repeat it, also, the field(s) on which you wish to filter, you need quotes.

    Assuming the field txt_name is numeric, and num_venderID is a control on the form, it could look something like this.

    =DLookUp("txt_name","tbl_P_Vendors","[ID]=" & [num_venderID])

    It might still barf, if there is no match
    Roy-Vidar

  3. #3
    Join Date
    Jul 2006
    Posts
    108
    i got it thank you i ended up using this:

    dlookup("txt_name",tbl_P_Vendors","ID=" & [num_VenderID])

    the problem was the fact that i had accidentily deleted the [num_venderID] field from my form so it was not being picked up

    The reason form naming the fields with prefixes TXT_ and num_ its for some reason it makes it so much easier for me to diffreinitriate(SP?) between the field on my form and fields in the table. im working with the same field multiple times but it may come from several tables so it can get confusing in my DB design..

  4. #4
    Join Date
    Dec 2003
    Location
    Dallas, TX
    Posts
    1,004

    Talking

    Quote Originally Posted by jwalker343
    i got it thank you i ended up using this:

    dlookup("txt_name",tbl_P_Vendors","ID=" & [num_VenderID])

    the problem was the fact that i had accidentily deleted the [num_venderID] field from my form so it was not being picked up

    The reason form naming the fields with prefixes TXT_ and num_ its for some reason it makes it so much easier for me to diffreinitriate(SP?) between the field on my form and fields in the table. im working with the same field multiple times but it may come from several tables so it can get confusing in my DB design..
    Hey JWalker,
    Naming conventions for fields etc. is good but you can maybe save a few keystrokes and thereby add a tab bit more speed if you do away with the underscore. Mine are labeled like this: [b]txtFName, cboCity, datEntryDate and so on. Not really all that much but thought it might help. I don't like having to do the underscore all the time as I did early on.

    have a nice one,
    BUD

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •