Results 1 to 2 of 2
  1. #1
    Join Date
    Dec 2009
    Posts
    8

    Unanswered: Pupulating SQL with Combo box data.

    Hello,
    I am trying to populate an sql row source with combo box data. Basicly Im trying to build a query by using 1 combo box (cmbSelect) to select data, that would build a query for another combo box (cmbSearch). Is this possible?

    This is the table where the 1st combo box pulls data (top row is field names)
    Code:
    table	        list	        id1	                        name
    tblArtists	Artists	        [tblArtists].[artist_id]	[tblArtists].[artist_name]
    tblTracks	Title	        [tblTracks].[track_id]	        [tblTracks].[title]
    This is the sql used in the second combo box
    Code:
    SELECT [Forms]![Form2]![cmbSelect].[column](2) as [Forms]![Form2]![cmbSelect].[column](1), 
    [Forms]![Form2]![cmbSelect].[column](3) 
    FROM [Forms]![Form2]![cmbSelect].[column](0) 
    UNION SELECT "*" As [Forms]![Form2]![cmbSelect].[column](1) ,
    " All" As [Forms]![Form2]![cmbSelect].[column](3) FROM [Forms]![Form2]![cmbSelect].[column](0) 
    ORDER BY [Forms]![Form2]![cmbSelect].[column](3);

    The idea is that if in the first combo box Artists is selected the combo box will display all the data from the tblArtists table, if title is selected it will display all the data from the tblTracks table.

    So for example if Artists was selected in the first combo box, the resulting query in the second combo box would be
    Code:
    SELECT [tblArtists].[artist_id] as filter, 
    [tblArtists].[artist_name] FROM tblArtists 
    UNION SELECT "*" As Filter ," All" As artist_name 
    FROM tblArtists 
    ORDER BY [artist_name];
    Theres probably an easier way of doing this, but Im just learning.

    Any Advice?

    Thanks
    Ron

  2. #2
    Join Date
    May 2008
    Location
    Big Lake, MN
    Posts
    18
    If I understood that right, and you're trying to sync comboboxes, this may be helpful.

    Synchronizing Combo Boxes on Forms in Access 2007
    If I had any wisdom to impart, I would do so here.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •