Results 1 to 4 of 4
  1. #1
    raynman1972 is offline Advanced Beginner
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2012
    Posts
    31

    Problem Populating ComboBox with Query Keyed off of other ComboBox

    Hello,



    I have one ComboBox, cboSnapshotDt, that allows the user to select a date value. I have a second ComboBox that populates from a query that uses the value from the first ComboBox (see code below). My problem is that I get zero returns from this query and I think that there is some issue with how the date value is being formatted. The query works to populate the second ComboBox if I remove the date condition, but only if I delete the second ComboBox and recreate it (it works initially without the date, but if I try to add the date parameter it doesnt work anymore even if I undo the query change).

    Is there some way to see what the query looks like when it runs, some kind of debug feature? Or is there something obvious that I am missing with including this variable in my work?


    Code:
    Me.cboForecastGrp.RowSource = "SELECT DISTINCT DEF_SKILLS.FORECAST_GROUP FROM DEF_SKILLS " & _
         " WHERE DEF_SKILLS.SNAPSHOT_DATE = " & Nz(Me.cboSnapshotDt) & _
         " ORDER BY DEF_SKILLS.FORECAST_GROUP DESC"

  2. #2
    rzw0wr is offline I will always be a newbie
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2013
    Location
    Indiana
    Posts
    479
    Try putting # signs around your date.
    WHERE DEF_SKILLS.SNAPSHOT_DATE =" & "#" & cboSnapshotDt & "#"

    Dale

  3. #3
    raynman1972 is offline Advanced Beginner
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2012
    Posts
    31
    That worked like a charm, thanks! One additional, is there syntax I should use when doing the same thing but with a string value?

  4. #4
    rzw0wr is offline I will always be a newbie
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2013
    Location
    Indiana
    Posts
    479
    Yes. Numbers do not need any quotes.

    "WHERE Number =" & number
    Variable or not.

    "Where Text ='" & Text & "'"

    If text is not a variable then,
    "Where Text = 'Text'"

    I think I have these correct.

    I am not very good with SQL stuff yet.


    Dale

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

Similar Threads

  1. Subform not populating from ComboBox
    By DMJ in forum Forms
    Replies: 3
    Last Post: 03-25-2013, 04:20 PM
  2. Form ComboBox not populating correctly
    By School Boy Error in forum Forms
    Replies: 13
    Last Post: 10-03-2012, 08:55 AM
  3. Replies: 4
    Last Post: 04-26-2012, 11:04 AM
  4. Form / combobox not populating
    By Auracle in forum Forms
    Replies: 7
    Last Post: 09-20-2011, 11:01 AM
  5. Replies: 5
    Last Post: 07-23-2011, 11:48 PM

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