Hi,
I have a combo box "cmbtimeframe" with the following code in the AfterUpdate event:
The idea is that the user can pick a value in the combo box (like One Month) and the SQL statement will return results for the last 30 days.
The problem is that the SQL statement is not picking up the value of the "HowLong" variable and it is instead displaying a box asking for that value. Once I enter is (7, for example), the query works fine.
What do I need to do so the HowLong variable is read into the SQL statement?
Thanks
mafhobb
I have a combo box "cmbtimeframe" with the following code in the AfterUpdate event:
Code:
Dim HowLong As Integer
Dim TimeFrame As String
cmbTimeFrame.SetFocus
TimeFrame = cmbTimeFrame.Value
If TimeFrame = "One Week" Then
HowLong = 7
ElseIf TimeFrame = "Two Weeks" Then
HowLong = 15
ElseIf TimeFrame = "One Month" Then
HowLong = 30
ElseIf TimeFrame = "Three Months" Then
HowLong = 90
ElseIf TimeFrame = "Six Months" Then
HowLong = 180
ElseIf TimeFrame = "One Year" Then
HowLong = 365
ElseIf TimeFrame = "Forever" Then
HowLong = 20000
End If
'SQL Query
Me.lstsearch.RowSource = "Select [SubCallID], [CallID], [SubCallDate], [SKU], [WhoPickedUp], [IssueType], [StatusAfterCall], [ResolutionDetails], [CustomerID] " & _
"From [EmployeeSearch] " & _
"Where ([subcalldate]>((Date())-[HowLong])) " & _
"And [WhoPickedUp] like '*" & Me.txtsearch & "*'"
Me.lstsearch.Requery
The idea is that the user can pick a value in the combo box (like One Month) and the SQL statement will return results for the last 30 days.
The problem is that the SQL statement is not picking up the value of the "HowLong" variable and it is instead displaying a box asking for that value. Once I enter is (7, for example), the query works fine.
What do I need to do so the HowLong variable is read into the SQL statement?
Thanks
mafhobb