Results 1 to 5 of 5
  1. #1
    Join Date
    Jan 2013
    Posts
    22

    Unanswered: Dlookup Error Message

    Hey Guys,

    I am trying to update a value by doing a dlookup and its giving me an error message. See attached.

    I am getting the error message on the following line of code:

    x2 = DLookup("[Region]", "Managers", "[Region] = '" & MName.Value & "'")
    Reg.Value = x2

    I just used it above that to get the MName values as below:

    x = DLookup("[Name]", "Managers", "[SID] = '" & Environ("UserName") & "'")
    MName.Value = x
    x1 = DLookup("[Who]", "Managers", "[Name] = '" & MName.Value & "'")
    Desg.Value = x1
    x2 = DLookup("[Region]", "Managers", "[Region] = '" & MName.Value & "'")
    Reg.Value = x2

    I know i might be making a small mistake but please help!

    Thank you in advance,
    Attached Thumbnails Attached Thumbnails Error Message.png  

  2. #2
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    what value is MName.value
    that error message suggests its null or not set.
    I'd rather be riding on the Tiger 800 or the Norton

  3. #3
    Join Date
    Jan 2013
    Posts
    22
    Hey Healdem,

    Thank you for your note. Here is the odd thing, when the code breaks due to the error message, and I hover over the MName.Value is see a value being pulled in.

    Secondly this same value is being used to update a textbox.

    So basically, I am trying to populate three TextBoxes, using a table of Managers. The first txtbox is pulling their name from table, second, their designation, and now the third which is region, i would like to get that as well.

    I would like to be able to run queries based on the Manager's location at a regional level, this is best way i could think off, I tried using a ComboBox or a ListBox, but the user still has to select the region, even though its just got one entry.

    Not sure if there is a smarter way around this? I would love to hear your thoughts.

    Kind regards,
    Nbkn8ct

  4. #4
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    so what datatype is x2?
    incidentally why not use meaningfull variabel names rather than x,x1,x2 (the days when you had to use shortened varaibale names is long long gone (was it car punch or fortran that caused that sort of approach)


    do you relly mean
    x2 = DLookup("[Region]", "Managers", "[Region] = '" & MName.Value & "'")

    that statement is either incorrect or useless
    you are looking for a region = mname.value and assigning the value of that to region

    presumably it shoudl be
    x2 = DLookup("[Region]", "Managers", "[Name] = '" & MName.Value & "'")

    you should be trapping for an error dlookup returns null if it cannot find a row
    I'd rather be riding on the Tiger 800 or the Norton

  5. #5
    Join Date
    Jan 2013
    Posts
    22
    Thank you Healdam!

    Apologies for seriously not coming back to you sooner! I realized my mistake in the code!

    Thank you again!.

Posting Permissions

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