Results 1 to 9 of 9
  1. #1
    apk19 is offline Advanced Beginner
    Windows 8 Access 2013
    Join Date
    May 2015
    Posts
    30

    DLookup returning #Error

    Hi people,

    I've been trying to simply populate a textbox based on the information in a combobox but keep returning #Error.




    The Numb combobox is labelled: [CbxRMA] and is the PK in a table "tblRMAs" with only two columns: a number "MARN" and the corresponding name "RMAName", which is the text I want displayed in the "Agent" textbox. The combobox value is stored in the form's underlying table not using a Lookup.

    The Control Source for the textbox is: =DLookUp("RMAName","tblRMAs","[MARN] = '" & [CbxRMA] & "'"). I have tried variations for [CbxRMA] with no luck.

    Any help is always appreciated.

  2. #2
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 8 Access 2013
    Join Date
    Aug 2013
    Posts
    7,862
    What is the RowSource of the Combo? In the property sheet, what is the value of the Column Count and Bound Column properties?

  3. #3
    apk19 is offline Advanced Beginner
    Windows 8 Access 2013
    Join Date
    May 2015
    Posts
    30
    Hi ItsMe,

    RowSource of the Combo is: SELECT tblRMAs.MARN, tblRMAs.RMAName FROM tblRMAs;
    Column Count: 2 (to display corresponding values)
    Bound Column: 1

  4. #4
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 8 Access 2013
    Join Date
    Aug 2013
    Posts
    7,862
    It sounds like your expression should consider the second column in your multicolumn combobox control. So something like this ...
    = DLookup("RMAName", "tblRMAs", "[MARN] = '" & Me.CbxRMA.Column(1) & "'")

    Having said that, why bother adding an unbound control that takes a second trip to the data to display something the combo can display? In other words, the value of RMAName is already in the combo's second column.

    You can adjust what is visible in a combo by adjusting the column widths property.

    The following will hide the first column and display the second.
    Column Widths: 0, 2.5

  5. #5
    apk19 is offline Advanced Beginner
    Windows 8 Access 2013
    Join Date
    May 2015
    Posts
    30
    Hi ItsMe,

    Thanks for the reply.

    I never really thought of that. Pretty stupid to not. I've been wanting a separate field for the sake of using it for templates, but I guess it can be derived straight from the table anyway.

  6. #6
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 8 Access 2013
    Join Date
    Aug 2013
    Posts
    7,862
    No worries, I know it can help to get a fresh set of eyes on things. You definitely want to be familiar with some of the properties of the combo. I have some screencast tutorials that you are welcome download. They go over the combo's properties and can be found here ...
    https://www.accessforums.net/tutoria...ers-52741.html

  7. #7
    apk19 is offline Advanced Beginner
    Windows 8 Access 2013
    Join Date
    May 2015
    Posts
    30
    I will definitely check it out.

    Thanks again.

  8. #8
    Missinglinq's Avatar
    Missinglinq is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Location
    Richmond (Virginia, not North Yorkshire!)
    Posts
    3,018
    Quote Originally Posted by apk19
    ...a number "MARN"...

    =DLookUp("RMAName","tblRMAs","[MARN] = '" & [CbxRMA] & "'")
    ItsME is correct, of course, about not making two trips to the data, when one trip will do, But just so that you know...your problem was that MARN is a Number, and your Where Clause

    Code:
    "[MARN] = '" & [CbxRMA] & "'"
    is only the correct syntax for a Text Field!

    For a Number Field it would have to be

    Code:
    "[MARN] = " & [CbxRMA]
    Linq ;0)>

  9. #9
    apk19 is offline Advanced Beginner
    Windows 8 Access 2013
    Join Date
    May 2015
    Posts
    30
    Thanks for the input. Managed to sort this one out. Full correct syntax is:

    =DLookUp("[RMAName]","tblRMAs","[MARN] = " & Nz([Forms]![Applicants]![CbxRMA],0))

Please reply to this thread with any new information or opinions.

Similar Threads

  1. DLookUp Not Returning Anything
    By Bkper087 in forum Access
    Replies: 5
    Last Post: 04-08-2015, 11:54 AM
  2. Replies: 3
    Last Post: 08-08-2012, 08:04 AM
  3. Dlookup returning #Error
    By ozziestockton in forum Forms
    Replies: 4
    Last Post: 07-30-2012, 10:53 AM
  4. Replies: 1
    Last Post: 10-20-2011, 07:37 AM
  5. Replies: 10
    Last Post: 05-19-2010, 10:34 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums