relax4delicutfew
Programmer
I am developing a database where I need to search through the data based on different critera. I am using combo boxes to do this, however I have run into a problem. Right now I have two combo boxes, and I want to be able to use each independently as well as a joint search.
I get in error due to the text I have in my tag for the combo boxes. The current code there is
Where=qryCombo1!RouteNumber.String.=
I also have =FillList() in the afterupdate
The currect code I have is
And I have a module
Any help is helping me get this work would be appreciated.
Thanks
Craig Weinschenk
I get in error due to the text I have in my tag for the combo boxes. The current code there is
Where=qryCombo1!RouteNumber.String.=
I also have =FillList() in the afterupdate
The currect code I have is
Code:
Option Compare Database
Option Explicit
Function FillList()
lstCrashes.RowSource = BuildWhere(Me)
lstCrashes.Requery
End Function
And I have a module
Code:
Option Compare Database
Function BuildWhere(frm As Form) As String
Dim ctl As Control
Dim var As Variant
Dim i As Integer
Dim strAnd As String
Dim strWhere As String
strWhere = vbNullString
strAnd = vbNullString
For Each ctl In frm.Controls
If (ctl.ControlType = acComboBox) Or (ctl.ControlType = acTextBox) Then
If (Len(ctl.Value) > 0) Then
If (InStr(ctl.Tag, "Where=") > 0) Then
MsgBox ctl.Tag
var = Split(ctl.Tag, ".")
If (var(1) = "String") Then
strWhere = strWhere & strAnd & "(" & Mid(var(0), 7) & var(2) & "'" & ctl.Value & "') "
ElseIf (var(1) = "Date") Then
strWhere = strWhere & strAnd & "(" & Mid(var(0), 7) & var(2) & "#" & ctl.Value & "#) "
Else
strWhere = strWhere & strAnd & "(" & Mid(var(0), 7) & var(2) & "'" & ctl.Value & "') "
End If
strAnd = " AND "
End If
End If
End If
Next
BuildWhere = strWhere
End Function
Any help is helping me get this work would be appreciated.
Thanks
Craig Weinschenk