Results 1 to 10 of 10
  1. #1
    Yensid is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Nov 2012
    Posts
    12

    Yet another auto fill question

    I have a table (tblAD) that stores "DocNumber" and "Description" information (i.e. AD-1001-001 = Widget).


    I have a form (frmECO).
    Two fields on this form are the focus of this question.
    The first field is "DocNumber", the second field is "Description".
    I want the "Description" field in the form to be automatically filled in with the description of the "DocNumber" based on the information from the table.
    For example: I want the user to enter AD-1001-001 in the "DocNumber" field on the form (frmECO) and I want the "description" field automatically filled in with Widget.

    I found the following code and have been trying to get it to work...unsuccessfully. Can anyone help?

    =DLookUp("[Description]","tblAD","[DocumentNumber] = " & [Forms]![DocumentNumber])

    Another thing that I am going to have trouble with is I have about 15 or so tables such as the "tblAD" that have "DocNumber" and "Description" information that I want to autofill based on the "DocNumber" entered on the form.
    So, a user could type in AD-1001-001 on the form and the description would automatically fill in with Widget (as explained before), but I also want that same form to allow the user to type in say CD-2224-003 - from a table called "tblCD", and autofill with that particular numbers description. I hope all of this makes sense.

    Thanks for your time!

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,623
    Why unsuccessful - error message, wrong results, nothing happens? DocNumber is a text field so need apostrophe delimiters for the criteria and the form name:

    =DLookUp("[Description]","tblAD","[DocumentNumber] = '" & [Forms]![formnamehere]![DocumentNumber] & "'")

    DLookup is really an inefficient method to retrieve related date on a form. I prefer:

    1. use multi-column combobox and then textboxes refer to combobox columns to display info

    2. include the reference table in form RecordSource joined on the ID fields, jointype "Include all records from PRIMARY table...", then textbox bound to fields of the reference table, Locked property Yes, TablStop property No.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    Yensid is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Nov 2012
    Posts
    12
    I got it to work ONCE with =DLookUp("[Description]","[tblAD]","[DocNumber] = '" & [Forms]![frmECO]![DocumentNumber] & "'") BUT ONLY ONCE. Now nothing will happen.

    I will have a go with your suggestion June7, but I don't know that I understand everything you wrote (my lack of knowledge)

  4. #4
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,623
    Maybe this will help for the combobox option http://datapigtechnologies.com/flash...combobox3.html
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  5. #5
    Yensid is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Nov 2012
    Posts
    12
    I don't think a combobox is what I want. Couple reasons

    1) I don't want to have the user scroll through 1000's of part numbers (the user will have the part number right in front of them) - they should be able to type the part number in one box, and have the description of that part number auto fill in another box.
    2) So far all the solutions I have seen would work for 1 table. I have about 20 tables that have different types of parts. For example, I have a tblCD for components, I have a tblAD for assemblies, tblFT for fixtures, tblOP for Standard Operating Procedure documents and so on.

    How can I have one box that a user will enter in any of those different kinds of document numbers, and there will be a box next to it that will autofill with the description of that particular document number?

  6. #6
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,623
    1. Don't have to scroll through combobox list. Type the value in the combobox, AutoExpand will match item in the list. Make combobox multi-column, one column for the part number and one for the description. The description can also be displayed in a textbox by expression referencing column of combobox. The tutorial demonstrates this. Yes, this is a 1 table solution.

    2. Would require VBA code that searches each table until value is either found and returned or not found and message to that effect returned. This could be a 'If Then ElseIf Else End If' structure. Review http://office.microsoft.com/en-us/ac...010341717.aspx OR build a UNION query that contains all the part numbers and descriptions from all 20 tables and use that query as data source for item 1 concept. A UNION query essentially presents the data in a normalized structure as it should be.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  7. #7
    Yensid is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Nov 2012
    Posts
    12
    Do you think it would make sense to put all item numbers (regardless of type) in the same table? Or do you think separating them out as I have (Assembly document, Operating documents, etc) into different tables is the best way to go? If I put them all in the same table, I wouldn't have to make a query...correct?

  8. #8
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,623
    Are the fields identical across the 20 tables?

    Either structure can be made to work. The multi-table version requires code or UNION. You have to decide which will work best for you. Seems one table is most optimized but I would have to know more about your data.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  9. #9
    Yensid is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Nov 2012
    Posts
    12
    I'll create the database so all document numbers and descriptions are in one table (tblDocuments). I will assign a document type designation (tblDocTypes) for each document in order to differentiate them. I'm sure I'll have more questions...

  10. #10
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,623
    The sounds like valid normalization. Good Luck.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

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

Similar Threads

  1. Auto fill
    By jojomac in forum Access
    Replies: 1
    Last Post: 10-10-2012, 09:57 AM
  2. Auto Fill
    By Scotty J in forum Forms
    Replies: 10
    Last Post: 11-21-2011, 10:08 AM
  3. Auto-fill
    By sidewayzalex in forum Database Design
    Replies: 49
    Last Post: 09-14-2011, 11:12 AM
  4. can't auto fill
    By chrisrach3 in forum Access
    Replies: 7
    Last Post: 09-12-2011, 04:41 AM
  5. Auto Fill
    By Kerrydunk in forum Forms
    Replies: 16
    Last Post: 04-26-2011, 12:15 AM

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