Results 1 to 9 of 9
  1. #1
    NickWren is offline Advanced Beginner
    Windows XP Access 2013
    Join Date
    Dec 2015
    Location
    Connecticut
    Posts
    70

    Mutlivalue Combobox Lookup field and a calculated field

    So I have a lookup field that takes multiple inputs if checked, however now I want to apply that field to a calculated field which uses both of the values
    My calculated field:
    [Location] & "-" & [ID] & "-" [TestType]

    TestType is the multivalue combobox that you can choose different tests, the TestType field gives both answers but how do i combine the answers to make it one word and then put it in the calculated field

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,522
    you dont. Multivalue combos cant integrate into queries. Not unless you know lots of VB.

    However you CAN make a point and click system WITHOUT vb, from a list box where the user picks items wanted, an append query runs and adds all picked items to a 'picked' table.
    The picked table can then be joined to your data table and pull ONLY items in the picked list.
    Click image for larger version. 

Name:	pick state-lbl.png 
Views:	17 
Size:	34.2 KB 
ID:	23272
    The user dbl-clicks the item in list,
    append qry add it to tPicked
    a delete query empties the table to start fresh
    Then your main query joins on the tPicked tbl to pull results.

  3. #3
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,894
    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.

  4. #4
    NickWren is offline Advanced Beginner
    Windows XP Access 2013
    Join Date
    Dec 2015
    Location
    Connecticut
    Posts
    70
    This is my VBA code so far, but I keep getting debug errors. Pretty much this code takes two commands buttons 1 goes to a "NETDataForm" while the other goes to "COLDataForm". However the samples dont always have both tests done, so I used a multivalue combobox to determine which tests are done, so If NETest was done the value in TestType should be "NET" while if the Colon test was done then the TestType should say "COL" and if both were done it should say "COL, NET" (alphabetically). But as of now I cant use an If than statement with the string it makes. (Debug: If CurTestType = "NET" Then)

    Code:
    Option Compare Database
    Private Sub Command55_Click()
    DoCmd.OpenForm "NETDataForm"
    End Sub
    Private Sub Command56_Click()
    DoCmd.OpenForm "COLDataForm"
    End Sub
    Private Sub Form_Load()
    Me.Command55.Visible = False
    Me.Command56.Visible = False
    End Sub
    Private Sub Form_Current()
    CurTestType = Me.TestType.Value
    Me.Refresh
    If CurTestType = "NET" Then
    Me.Command55.Visible = True
    ElseIf CurTestType = "COL" Then
    Me.Command56.Visible = True
    ElseIf CurTestType = "COL, NET" Then
    Me.Command55.Visible = True
    Me.Command56.Visible = True
    End If
    End Sub
    Ik ranman said it is difficult to make a query using the multivalue combobox, but I do need to know how to do this, so how is that possible using this code for a search query?
    Code:
     LIKE "*" & Forms!SearchSampleForm!TestType.Combobox.Value & "*"

  5. #5
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,894
    Did you review the links provided? I NEVER use multi-value fields.

    If you want to pull individual values from multi-value field, need query that expands the values to individual records. I provided link to example for that.

    You must understand that "COL, NET" is not what is stored in a multi-value field. "COL, NET" is a single text string. A multi-value field does not store a single text string. A multi-value field is really a 'link' to a hidden dependent table - basically what you would do if you built a normalized structure, only you would be able to see the dependent table.

    Therefore a multi-select combobox does not have a single text string as a value and your If Then conditional code fails.

    Suggest a normal text field and combobox with options of COL, NET, BOTH and adjust your code accordingly.
    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.

  6. #6
    NickWren is offline Advanced Beginner
    Windows XP Access 2013
    Join Date
    Dec 2015
    Location
    Connecticut
    Posts
    70
    O... I see, theres no way of combining the two stored values? I tried to store the value inside another hidden textbox, and it comes out saying "COL, NET" I cant use that value? because isnt this a string now from the hidden textbox?

  7. #7
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,894
    How do you accomplish setting value of textbox?

    Code would reference the hidden textbox, not the combobox.

    I really don't see need for multi-value field/combobox.
    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.

  8. #8
    NickWren is offline Advanced Beginner
    Windows XP Access 2013
    Join Date
    Dec 2015
    Location
    Connecticut
    Posts
    70
    The need for the combobox is so that we dont have the same sample entered twice with the only difference being the test we are running on it. it is ideal to get this multivalued combobox answer into a string to determine which form to go to next.

    If anything I guess a checkbox to say yes we are doing this test or yes we are doing that test would work also. Then using an if than statement to open up the forms with the "yes".

  9. #9
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,894
    My suggestion of normal text field and combobox with options of COL, NET, BOTH would not require multiple sample records.

    Are COL and NET the only test types involved?
    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. Replies: 2
    Last Post: 12-30-2014, 01:32 PM
  2. Replies: 3
    Last Post: 05-31-2014, 11:37 AM
  3. Replies: 1
    Last Post: 04-21-2013, 03:20 PM
  4. Replies: 3
    Last Post: 02-13-2013, 10:15 AM
  5. Calculated Field in Combobox
    By confusedlilly19 in forum Forms
    Replies: 1
    Last Post: 06-22-2012, 01:44 AM

Tags for this Thread

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