Results 1 to 3 of 3
  1. #1
    2 Star Lounger
    Join Date
    Mar 2001
    Location
    Colorado, USA
    Posts
    144
    Thanks
    0
    Thanked 0 Times in 0 Posts

    DLookup Funny Business (Access 2000)

    I've got an application in which the table bound to the form contains a field named "Description". There is also a combobox on the form that gets its row source info from a different table that also contains a field named description. I have a textbox on the form that is supposed to display the contents of the second description field after the combobox updates. I first thought I could put an =Dlookup(...) statement in the control source for the text box to do the job, but I'd get the contents of the first description field, instead. So, I tried putting similar code in the AfterUpdate event for the combobox, but I get the same results. In both cases, I explicitly state the second table as the domain for DLookup. Any ideas of what might be going on here?

    The Dlookup looks like this (note the form is bound to a table tblSoftware which contains a field Description):
    DLookup("[Description]","tblSeverityLevels","([Level] = " & me.cboSeverityLevel & ")")

    I thought this would be a simple thing, but it's not turning out that way.

    Thanks.

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: DLookup Funny Business (Access 2000)

    I don't understand how the DLookup you use could return a description from tblSoftware. there are some alternatives:

    1. You can add the description field to the cboSeverityLevel combo box as an extra column, which may be hidden (by setting its column width to 0) if you don't want the user to see it in the dropdown list. Say that it is the third column in the combo box. The control source of the description text box would be

    =[cboSeverityLevel].[Column](2)

    for the column index is zero-based: 0 is the first column, 1 the second, etc.

    2. You can create a query based on tblSoftware and tblSeverityLevels, with an outer join (all records from tblSoftware); add the Description field from tblSeverityLevels to the query grid beside the fields from tblSoftware and give it an appropriate alias, e.g. SeverityDescription. Use the query as Record Source of the form, and set the control source of the text box to SeverityDescription.

  3. #3
    2 Star Lounger
    Join Date
    Mar 2001
    Location
    Colorado, USA
    Posts
    144
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: DLookup Funny Business (Access 2000)

    The Column solution worked great. Thanks for the pointer. I don't understand why DLookup did what it did either, but now I guess I don't care as much.

    Thanks again for the help.

Posting Permissions

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