Why does the combobox not find the value?

cheberdy

Member
Local time
Tomorrow, 00:47
Joined
Mar 22, 2023
Messages
77
I have this code that is used to select queries using a combo box(Timecombo), and in turn select data from the queries using another combo box(Itemcombo). This data is used to find a value of a form. Until now there is only one case statement. This all works except that the value is not found in the form.

Code:
Private Sub Timecombo_Change()
     Select Case Timecombo.Value
        Case "Months"
            Me.Itemcombo.RowSource = "SELECT itemname FROM day ORDER BY itemname;"
    End Select
End Sub
 
what value do you expect?
is the value in your SELECT statement?

to return the first Item:
Code:
Private Sub Timecombo_Change()
     Select Case Timecombo.Value
        Case "Months"
            Me.Itemcombo.RowSource = "SELECT itemname FROM day ORDER BY itemname;"
            Me.Itemcombo = Me.Itemcombo.ItemData(0)
    End Select
End Sub
 
Start walking through your code using F8. It will help you immensely in the future, if you are going to continue with Access.
See my signature for debugging. Plenty of YouTube videos out there as well.

So, in that regard, make sure that the value is what you think it is. If that was my combo, the combo would consist of an ID and display field that would show "Months" ?
 
Do you have any Starter book for Ms Access?
you should so you can read and have basic understanding
of common things.
if you want, i can give you.
PM is the key.
 
Do you have any Starter book for Ms Access?
you should so you can read and have basic understanding
of common things.
if you want, i can give you.
PM is the key.
Access for Dummies was given to me, a good while back. :)
 
what value do you expect?
is the value in your SELECT statement?

to return the first Item:
Code:
Private Sub Timecombo_Change()
     Select Case Timecombo.Value
        Case "Months"
            Me.Itemcombo.RowSource = "SELECT itemname FROM day ORDER BY itemname;"
            Me.Itemcombo = Me.Itemcombo.ItemData(0)
    End Select
End Sub
it is in itemname in day
 
I have this code that is used to select queries using a combo box(Timecombo), and in turn select data from the queries using another combo box(Itemcombo). This data is used to find a value of a form. Until now there is only one case statement. This all works except that the value is not found in the form.

Code:
Private Sub Timecombo_Change()
     Select Case Timecombo.Value
        Case "Months"
            Me.Itemcombo.RowSource = "SELECT itemname FROM day ORDER BY itemname;"
    End Select
End Sub
Day is a reserved word.
You should also probably be using the afterupdate event.
 
You seem to have left out a step in the description. Combo1 is changing the rowsource of combo2. Is that working correctly? Then you want to use combo2 as the Where value for a query. Is that the problem? When you run the query with the Where clause pointing to that combo, you find no results? Have you perhaps used a table level lookup so that you don't know what value actually exists in the table. You could be looking for ItemName but the table might actually contain ItemID.
 

Users who are viewing this thread

Back
Top Bottom