Results 1 to 7 of 7
  1. #1
    bnefit is offline Novice
    Windows 10 Office 365
    Join Date
    Jul 2020
    Posts
    3

    How to display text from 2 Combo Boxes selections?

    Hi



    I am new to Access and to the forum. I am trying to build a database and currently have a problem in Forms that require assistance.

    I have created the following in Access:
    Query: _Test & Tag



    In Forms, I have created 2 Combo Boxes which I have labelled as Location (Combo33) and Description (Combo37). I have also created a Text Box labelled as Current Test Date (Text40).




    For Combo33 (Location), I want to have a dropdown list of the various locations so I have set the Row Source as:
    SELECT DISTINCT [_Test & Tag].Location FROM [_Test & Tag] ORDER BY [_Test & Tag].[Location];

    For Combo37 (Description), the list of items will depends on the location so I have set the Row Source as:
    SELECT [_Test & Tag].Description FROM [_Test & Tag] WHERE Combo33=[_Test & Tag]!Location ORDER BY [_Test & Tag].[Description];

    For Text40 (Current Test Date), I would like to display the Test Date from _Test & Tag depending on the selection of Combo33 and Combo37. However, I am having trouble trying to get this to work.

    I have tried to set the Control Source to DLookup([Test Date],[_Test & Tag],[Combo33]= & Forms!Test & TagUpdate2!Location, [Combo37]= & Forms!Test & TagUpdate2!Description) but it didn't work.

    Thanks for reading and any ideas/help would be greatly appreciated.

  2. #2
    Bob Fitz is offline Access Developer
    Windows 10 Access 2016
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    2,507
    Include [Test Date] as a column in Combo37. You can hide it if you wish by setting its Column Width property to 0.
    Set the Control Source of Text40 to:

    =Combo37.Column(#?) Replace #? with the column number that is holding the [Test Date] value.
    Keep in mind, when counting the columns that they are zero based, so the first column is numbered 0 the second is 1, the third is 2 etc.

    BTY it would be better to NOT use spaces in the names given to objects in Access. TestDate would be better than [Test Date]. The square brackets are only needed because of the space.
    Also, give meaningful names to the controls on forms e.g. cmbLocation/cmbDescrip/txtTextDate
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  3. #3
    Bob Fitz is offline Access Developer
    Windows 10 Access 2016
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    2,507
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  4. #4
    mike60smart is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    May 2018
    Location
    Living in Scotland UK
    Posts
    374
    Hi

    I would suggest that you look at your table structures.

    Your query is based on 1 Table but I would suggest that you need at least 2

    1 table for the Location and another for the Items at that Location.

  5. #5
    bnefit is offline Novice
    Windows 10 Office 365
    Join Date
    Jul 2020
    Posts
    3
    Hi Bob

    Apologies for cross posting and thanks for letting me know. I won't make the same mistake again.

  6. #6
    bnefit is offline Novice
    Windows 10 Office 365
    Join Date
    Jul 2020
    Posts
    3
    Thanks to all who have replied and your suggestions. Apologies that I have cross-posted this question in another forum as I did not familiarise myself with the rules.

    Nonetheless, I would like to share the solution that was provided by a member as follows. Thanks All

    =DLookup("[Test Date]", "[_Test & Tag]", "[Location]='" & Combo33 & "' AND [Description]='" & Combo37 & "'")

  7. #7
    pbaldy's Avatar
    pbaldy is online now Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    21,320
    Post 5 was moderated, I'm posting to trigger email notifications.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

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

Similar Threads

  1. Replies: 1
    Last Post: 02-06-2016, 05:33 AM
  2. Linking Combo boxes and Text boxes
    By Nathan4477 in forum Forms
    Replies: 6
    Last Post: 07-29-2015, 08:50 AM
  3. Replies: 9
    Last Post: 06-04-2014, 10:45 AM
  4. Combo Boxes, Selections, frustrations
    By redbull in forum Programming
    Replies: 14
    Last Post: 10-23-2012, 11:41 AM
  5. Replies: 3
    Last Post: 05-25-2010, 02:16 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 - Senior Forums