Results 1 to 6 of 6

Thread: dlookup (2000)

  1. #1
    4 Star Lounger
    Join Date
    May 2003
    Location
    Manchester, Gtr Manchester, England
    Posts
    552
    Thanks
    0
    Thanked 0 Times in 0 Posts

    dlookup (2000)

    I have a dooklup on an event thus Me.polt = DLookup("[Type of contract]", "tbl_Contracts", "[ID] = Forms![Main Form]![question subform1]![contract] "). How do I code it so I put the table and field that polt is bound to instead of using polt?

    Thanks Darren.

  2. #2
    Silver Lounger
    Join Date
    Jun 2002
    Location
    Cheadle, Staffordshire
    Posts
    2,177
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: dlookup (2000)

    Not sure what you mean here, but I think you are trying to set the field to be bound.

    The statement:-
    Me.polt = DLookup("[Type of contract]", "tbl_Contracts", "[ID] = Forms![Main Form]![question subform1]![contract] ")

    Remove the "Me.polt" ie

    = DLookup("[Type of contract]", "tbl_Contracts", "[ID] = Forms![Main Form]![question subform1]![contract] ")

    And put this in the control source of the field via it's properties.

    If this isn't what you needed, could you explain further.

  3. #3
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: dlookup (2000)

    If the control is bound to a field in a table, then setting the value of the control also sets the value in the table. Is that what you're asking?
    Charlotte

  4. #4
    4 Star Lounger
    Join Date
    May 2003
    Location
    Manchester, Gtr Manchester, England
    Posts
    552
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: dlookup (2000)

    Thanks guys, I'll try to make myself clearer, the current dlookup puts a value in a hidden control on the form i.e. polt, that then obviously populates the field it is bound to. I can't help but think there is a slicker way than having a hidden control so that the field is populated direct, for ref the control polt is bound to pol_type on tbl_question.


    Kind regards Darren.

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

    Re: dlookup (2000)

    Hi Darren,

    Although it would be possible to write the value directly to the table, it is not a good idea. When you move to another record in the form, you'd probably get an error message that another process or user changed the record while you were editing it in the form. Using a hidden control may seem clunky to you, but it is in fact an elegant way to let Access take care of storing the value in the underlying table.

    I don't know enough about the setup, but perhaps you don't really need to store the value, since it is a lookup. You might be able to create a query that performs the lookup on the fly.

  6. #6
    4 Star Lounger
    Join Date
    May 2003
    Location
    Manchester, Gtr Manchester, England
    Posts
    552
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: dlookup (2000)

    That's fine Hans, it does what I want to achieve as things are so in the wrods of the adage 'if it ain't broken...'. Thanks for your guidance.

    Darren.

Posting Permissions

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