I'm pretty sure there's a simple solution to this, yet I can't seem to find it.
I have a table that contains the Months of the year with an MonthID:
1|January
2|Febuary
...
I also have a form that contains a combobox with the Months.
When the user chooses the month, a query gets created, returning the MonthID.
I want to store the MonthID, in an invisible textbox, so that I can use it for my calculations.
If I use a textbox, I can't seem to display the result and if I use a listbox, I can't access that value.
How would I make it work?
This is the code used on the combobox:
I have a table that contains the Months of the year with an MonthID:
1|January
2|Febuary
...
I also have a form that contains a combobox with the Months.
When the user chooses the month, a query gets created, returning the MonthID.
I want to store the MonthID, in an invisible textbox, so that I can use it for my calculations.
If I use a textbox, I can't seem to display the result and if I use a listbox, I can't access that value.
How would I make it work?
This is the code used on the combobox:
Code:
Private Sub cbToMonth_Change()
Dim db As DAO.Database
Dim qdf As DAO.QueryDef
Dim strSQL As String
Set db = CurrentDb()
Set qdf = db.QueryDefs("getMonthID")
strSQL = "SELECT Months1.MonthID " & _
"FROM Months1 " & _
"WHERE (((Months1.Month) In ('" & Me.cbToMonth.Value & "')));"
qdf.SQL = strSQL
Me.monthIDTo.Value = "getMonthID"
Set db = Nothing
Set qdf = Nothing
End Sub
Last edited: