Results 1 to 5 of 5
  1. #1
    4 Star Lounger
    Join Date
    Sep 2002
    Location
    Stafford, Staffordshire, England
    Posts
    585
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Dlookup - Yet again! (A2002)

    I have form [frmInvoice] which contains a combobox [cboConsultant] that provides a lists of consultants. I have a second combobox [cboConID] in which I hope to display the ConsultantID based on the selected Consultant. I am using this in the row source of [cboConID]:

    =Dlookup("[ConsultantID]";"[Consultant Table]";"[Forms]![frmInvoice]![cboConsultant]"

    Ihave set the row source type to Field List and the control source to ConsultantID.

    However, when I run the form, cboConID remains blank.

    I must be doing something wrong. <img src=/S/groan.gif border=0 alt=groan width=16 height=15> Help would be appreciated.
    TIA.
    <font color=blue><font face="Script MT Bold"><big>Rob</big></font face=script></font color=blue>

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

    Re: Dlookup - Yet again! (A2002)

    The Row Source property does not fill the value of a combo box, it only populates the dropdown list. DLookup only returns one value, so it is not suitable to populate a list.

    Why do you need two combo boxes for consultants?

  3. #3
    4 Star Lounger
    Join Date
    Sep 2002
    Location
    Stafford, Staffordshire, England
    Posts
    585
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Dlookup - Yet again! (A2002)

    Thanks for the reply.
    The Consultant combobox is for the user to make a selection. This gives the full name of the doctor which is required in some reports. I intend to hide the cboConID but I will use its value to make queries for other reports. I just need the box to display the appropriate ConsultantID and store its value in the Invoice Table. Does that make sense?
    <font color=blue><font face="Script MT Bold"><big>Rob</big></font face=script></font color=blue>

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

    Re: Dlookup - Yet again! (A2002)

    The "proper" way to do this is to use a combo box cboConsultant bound to ConsultantID whose row source is a query based on Consultant Table that returns ConsultantID and the consultant's name, sorted on the consultant name column. The Column Count property of the combo box should be set to 2, and the Column Widths property to 0";1".
    The combo box will display the consultant's name, but store the ConsultantID field.

    If you need to refer to the consultant's name on another form or report, you can use

    =[Forms]![frmInvoice]![cboConsultant].[Column](1)

  5. #5
    4 Star Lounger
    Join Date
    Sep 2002
    Location
    Stafford, Staffordshire, England
    Posts
    585
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Dlookup - Yet again! (A2002)

    Many thanks, Hans.. It's always good to do things the "proper way". <img src=/S/grin.gif border=0 alt=grin width=15 height=15>
    <font color=blue><font face="Script MT Bold"><big>Rob</big></font face=script></font color=blue>

Posting Permissions

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