B
BigNasty
Im trying to create a search function for my access application. I
would like users to be able to select values from drop down boxes. When
the user hits OK, the Openform method will open up the access form with
the required criteria based on the selections the user name. My problem
is putting the string together. If a user selects the 2nd and 3rd combo
box but not the first based on my code below i have a "AND" statement
in front of my search string.
Here is the code im using:
Private Sub cmdOK_Click()
On Error GoTo Err_cmdOK_Click
Dim strWhere As String
Dim strWhere1 As String
Dim strWhere2 As String
Dim strTotal As String
If Not IsNull(cboLobName) Then
strWhere = "[Line Of Business]=" & cboLobName
Else
strWhere = " "
End If
If Not IsNull(cboSDLead) Then
strWhere1 = "[SD Lead] = " & cboSDLead
Else
strWhere1 = " "
End If
If Not IsNull(cboStatus) Then
strWhere2 = "[Status] = " & cboStatus
Else
strWhere2 = " "
End If
strTotal = strWhere & " " & " " & strWhere1 & " " & strWhere2
Text18 = strTotal
I would like it so that no matter what selection the user makes the
correct string is put together.
would like users to be able to select values from drop down boxes. When
the user hits OK, the Openform method will open up the access form with
the required criteria based on the selections the user name. My problem
is putting the string together. If a user selects the 2nd and 3rd combo
box but not the first based on my code below i have a "AND" statement
in front of my search string.
Here is the code im using:
Private Sub cmdOK_Click()
On Error GoTo Err_cmdOK_Click
Dim strWhere As String
Dim strWhere1 As String
Dim strWhere2 As String
Dim strTotal As String
If Not IsNull(cboLobName) Then
strWhere = "[Line Of Business]=" & cboLobName
Else
strWhere = " "
End If
If Not IsNull(cboSDLead) Then
strWhere1 = "[SD Lead] = " & cboSDLead
Else
strWhere1 = " "
End If
If Not IsNull(cboStatus) Then
strWhere2 = "[Status] = " & cboStatus
Else
strWhere2 = " "
End If
strTotal = strWhere & " " & " " & strWhere1 & " " & strWhere2
Text18 = strTotal
I would like it so that no matter what selection the user makes the
correct string is put together.