Results 1 to 6 of 6
  1. #1
    Join Date
    Nov 2003
    Posts
    66

    Unanswered: How to get a dlookup value on a form into the form's underlying table

    I have a data entry form based on a 'Shareholdings' table. One of the fields on the form is populated from a different table using dlookup.
    Because the control source for this particular field contains the lookup expression, it's no longer linked to its underlying field in the shareholdings table - how can I get the auto populated value for that field on the form back into it's associated field in the table?
    Am I going about this the wrong way?

    Apologies for another dumb question.....

  2. #2
    Join Date
    Nov 2003
    Posts
    267
    I have to admit that I would rarely reccommed using DLookup function.

    It sounds like you are using a bound form. If so do the following

    1. Create a query based on the other table, where your lookup values are
    2. Put a combo box on your data entry form that is bound to the field you want in the main table (control Source)
    3. Tie the combo bax to the query to get the list of valid choices (Row Source)

    Then when you select you choice in the combo box, it will act just like you typed it into a text box.

    S-

  3. #3
    Join Date
    Nov 2003
    Posts
    66
    Thanks - had a look, and it certainly sounds like a better way to approach this. What I didn't mention in my post is that the possible values for the 'lookup' field are determined by a selection the user makes in another combo box in the same record. Easy enough to solve using dlookup, but as mentioned, I can't do anything with the values once they're displayed.
    Using your combo box idea rather than a dlookup to display the required values looks like the way to go - now I have to work out how to limit the selectable values in the 2nd combo based on the selection made in the first. I've seen posts in here dealing with the same problem - being a novice in Access and db's in general, the thoughts of deciphering VB code is a bit daunting - this could take a while.

    Cheers for the help!
    D

  4. #4
    Join Date
    Nov 2003
    Posts
    267
    BAse your second combo box on a query that looks to the first combo box for its parameter. In the got focus of the second combo box add teh following code to refersh the combo box to the new parameter

    combobox.requery

    S-

  5. #5
    Join Date
    Nov 2003
    Posts
    66
    Hi sbaxter - I tried setting the value of combo2 in an afterupdate event contained in combo1, but that's giving me a blank dropdown in combo2 when I run it. Dunno if it's a problem with the syntax (I have zero VB experience). I've put the details in a seperate post on here if your arsed taking a look...

    Thanks,
    Dave

  6. #6
    Join Date
    Nov 2003
    Posts
    66
    Nevermind - got it working. Turns out it was a syntax problem after all....

    Cheers,
    D

Posting Permissions

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