@Jim Doherty
Thanks for the demo db. It is an impressive and exhaustive learning resource. I will save it and use it for my future projects.
@TheSmileyOne, your code worked perfectly! Here is what it looks like:
- Dim strWhere As String
-
-
strWhere = " Where 1 = 1"
-
-
If Not IsNull(Me.cmb_MediaType) Then
-
If strWhere & "" <> "" Then strWhere = strWhere & " AND "
-
strWhere = strWhere & " MediaType='" & Me.cmb_MediaType & "'"
-
End If
-
-
If Not IsNull(Me.cmb_City) Then
-
If strWhere & "" <> "" Then strWhere = strWhere & " AND "
-
strWhere = strWhere & " Industry='" & Me.cmb_City & "'"
-
End If
-
-
If Not IsNull(Me.cmb_market) Then
-
If strWhere & "" <> "" Then strWhere = strWhere & " AND "
-
strWhere = strWhere & " City='" & Me.cmb_market & "'"
-
End If
-
-
If Not IsNull(Me.CmbMediaName) Then
-
If strWhere & "" <> "" Then strWhere = strWhere & " AND "
-
strWhere = strWhere & " MediaName='" & Me.CmbMediaName & "'"
-
End If
-
-
If Not IsNull(Me.cmb_Client) Then
-
If strWhere & "" <> "" Then strWhere = strWhere & " AND "
-
strWhere = strWhere & " Client='" & Me.cmb_Client & "'"
-
End If
-
-
If Not IsNull(Me.cmb_Lastname) Then
-
If strWhere & "" <> "" Then strWhere = strWhere & " AND "
-
strWhere = strWhere & " Lastname='" & Me.cmb_Lastname & "'"
-
End If
-
-
If Not IsNull(Me.cmb_Title) Then
-
If strWhere & "" <> "" Then strWhere = strWhere & " AND "
-
strWhere = strWhere & " Title='" & Me.cmb_Title & "'"
-
End If
-
-
-
strSql = "select * from Master_Media_List" & strWhere & ";"
-
Me.RecordSource = strSql
Having tackled this, there are a couple of additional problems:
I also have a "Reset" button on that same form, that resets all comboboxes. However it does not reset the form in its original state- when it was first opened. Please let me know what I am doing wrong:
- Private Sub btn_Reset_Click()
-
-
Dim ctl As Control
-
For Each ctl In Me.Controls
-
-
Select Case ctl.ControlType
-
-
Case acComboBox
-
ctl.Value = Null
-
-
End Select
-
Next ctl
-
-
Me.Requery
-
-
End Sub
Secondly, how can I modify the code so that hitting "Enter" on the keyboard would run the query, instead of having to click the search button?
Thanks for all your help!