Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
Private Function fncGenerateQuery() As Boolean
Dim strSQL As String
Dim qdfTemp As QueryDef
Dim strWhere as String 'Dim'd a new var to hold the where clauses
strSQL = "SELECT * FROM visitors ";
If not (Me.cboDivision.Value = vbNullString) then
If len(strWhere) > 0 then
strWhere = strWhere & " WHERE "
Else
strWhere = strWhere & " AND "
Endif
strWhere = strWhere & " Division = '" & Me.cboDivision.Value & "'";
Endif
If not (Me.cboRegion.Value = vbNullString) then
If len(strWhere) > 0 then
strWhere = strWhere & " WHERE "
Else
strWhere = strWhere & " AND "
Endif
strWhere = strWhere & " Region = '" & Me.cboRegion.Value & "'";
Endif
If (not (isnull(me.txtStart.Value))) And (not (isnull(me.txtEnd.Value))) then
If len(strWhere) > 0 then
strWhere = strWhere & " WHERE "
Else
strWhere = strWhere & " AND "
Endif
strWhere = strWhere & " AssignDate Between #" & Format(me.txtStart.Value,"MM/DD/YY") & "# AND #" & Format(me.txtEnd.Value, "MM/DD/YY") & "#"
Endif
strSQL = strSQL & strWhere
Set qdfTemp = CurrentDb.QueryDefs("qryMain")
qdfTemp.SQL = strSQL
Set qdfTemp = Nothing
fncGenerateQuery = True
End Function
strSQL = "SELECT * FROM visitors WHERE 1 = 1"
If not (Me.cboDivision.Value = vbNullString) then
strSQL= strSQL & " AND Division = '" & Me.cboDivision.Value & "'"
Endif
If not (Me.cboRegion.Value = vbNullString) then
strSQL = strSQL & "; AND Region = '" & Me.cboRegion.Value & "'";
Endif
If (not (isnull(me.txtStart.Value))) And (not (isnull(me.txtEnd.Value))) then
strSQL = strSQL & " AND AssignDate Between #" & Format(me.txtStart.Value,"MM/DD/YY") & "# AND #" & Format(me.txtEnd.Value, "MM/DD/YY") & "#&"
Endif