Results 1 to 4 of 4
  1. #1
    joshlee is offline Novice
    Windows XP Access 2003
    Join Date
    May 2009
    Posts
    2

    Lookup Form (should be simple)

    I know this is probably very simple, but I am stumped.



    What I am trying to do is create a form for looking up part numbers.

    In the database is a column of "our part numbers" alongside a column of "vendor part numbers".

    I want to create a form that has two text boxes, one for "our part numbers" the other for "vendor part numbers".

    When I type in the vendor number in the "vendornum" text box, I want the "partnum" text box to update to the correct record that matches.

    The closest I have come to doing this is creating a table with both of these columns, then creating a form and adding this code to a command button click.

    Code:
    Private Sub Refreshbutton_Click()
        vendornumbox = DLookup("vendornum", "main", "partnumbox" & partnum)
    End Sub
    Basically what I was thinking this code would do is, when you click the Refresh command button it will fill the vendor number box with the vendor number matching the part number as specified in the part number box.

    However, all it does is no matter what I put in the part number box always update it to the first record in the vendornum column.

    Any help would be much appreciated.

    TIA

  2. #2
    CraigDolphin is offline Competent Performer
    Windows XP Access 2000
    Join Date
    Apr 2009
    Location
    Custer, WA, USA
    Posts
    125
    Try:
    vendornumbox = DLookup("vendornum", "main", "[partnum]='" & partnumbox & "'")

    This assumes that both the field and the partnumbox control both are text values, not numbers. If they are numeric, remove the singlequotes

  3. #3
    joshlee is offline Novice
    Windows XP Access 2003
    Join Date
    May 2009
    Posts
    2
    thank you very much. was becoming a big headache, you saved me from the simple mistake.

  4. #4
    CraigDolphin is offline Competent Performer
    Windows XP Access 2000
    Join Date
    Apr 2009
    Location
    Custer, WA, USA
    Posts
    125
    Glad it worked for you

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

Similar Threads

  1. Simple Nav Form Code Not Working
    By alsoto in forum Forms
    Replies: 10
    Last Post: 04-10-2009, 09:30 AM
  2. Lookup Form
    By virgiljones in forum Access
    Replies: 0
    Last Post: 10-17-2008, 10:39 PM
  3. Lookup Form
    By cav0227 in forum Forms
    Replies: 0
    Last Post: 04-16-2007, 09:23 AM
  4. Lookup
    By neon'00 in forum Forms
    Replies: 2
    Last Post: 04-14-2007, 01:19 PM
  5. Simple record lookup?
    By Transeau in forum Access
    Replies: 0
    Last Post: 01-18-2006, 10:27 PM

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