Results 1 to 3 of 3
  1. #1
    Daisy509th's Avatar
    Daisy509th is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Jan 2018
    Location
    Central Texas
    Posts
    51

    Returning Multiple values from one combo box

    Click image for larger version. 

Name:	2018-04-11 (2).png 
Views:	6 
Size:	34.4 KB 
ID:	33511

    I am using VBA to create the file path located in the textbox. I have everything I need in the path except the last name.

    D:\Users\druss\Lauren Concrete\Digtal Libary-DOT Paperwork\Drivers\Alberto\4132018TS.pdf (This is missing last name "Saenz")

    D:\Users\druss\Lauren Concrete\Digtal Libary-DOT Paperwork\Drivers\Alberto Saenz\4132018TS.pdf (This is what I need)

    Dim strMonth As String, strDay As String, strYear As String, strPresentation As String


    strMonth = DatePart("m", Me.Combo197)
    strDay = DatePart("d", Me.Combo197)


    strYear = DatePart("yyyy", Me.Combo197)


    If IsNull(Me.Combo233) Then Exit Sub


    MsgBox Me.Combo233
    strPresentation = "D:\Users\druss\Lauren Concrete\Digtal Libary-DOT Paperwork\Drivers" & Me.Combo233 & "" & ""
    strPresentation = strPresentation & strMonth & strDay & strYear & "TS" & ".pdf"
    Me.Text229 = strPresentation
    (On a side note can someone teach me how I would add error checking to this code. I know I need to start error checking all my code)


    The combo box is showing both values in the drop down but I cant figure out how to grab the second value.

    Thanks for the help
    Last edited by Daisy509th; 04-11-2018 at 05:56 AM. Reason: Added Code/Error Checking

  2. #2
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    5,977
    Either use me.combo233 & " " & me.combo233.column(1) assuming last name is the 2nd column

    Or add an extra hidden column to your combo the use that in your code
    [firstname] & " " & [lastname]

    Suggest you actually display that column instead.
    First name alone not helpful when there are more than one e.g. Antonio

    There are plenty of articles on error handling if you do a google or site search
    Colin, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I don't know, I keep quiet!
    If I don't know that I don't know, I don't know whether to answer

  3. #3
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,430
    use the column property

    & Me.Combo233 & " " & me.combo233.column(2)


    note that you do not appear to be using a primary key, so the chances are if you select Antonio Lopez, it will return Antonio Perez because that is the first firstname it will find

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

Similar Threads

  1. Replies: 5
    Last Post: 11-19-2017, 12:28 PM
  2. Replies: 4
    Last Post: 02-11-2016, 02:34 AM
  3. Replies: 9
    Last Post: 08-30-2015, 05:44 PM
  4. Replies: 2
    Last Post: 02-26-2015, 03:20 PM
  5. Saving multiple values in look-up combo box
    By AnnSparks in forum Database Design
    Replies: 5
    Last Post: 01-23-2015, 02:18 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