H
Hafeez Esmail
I'm trying to make a form that will ease the process of
making a query for my users.
The users want to be able to view a query based what ever
constraints they select on the form (in the form of
checkboxes).
The base of the query is:
Set qdfTemp = CurrentDb.CreateQueryDef("qrySteveCustom",
strSQL)
strSQL starts off as:
strSQL = "SELECT * FROM tblOne"
strSQL
When the user checkmarks a box, strSQL gets updated and
will now read:
strSQL = strSQL & " WHERE (tblOne!Field1 = strConstraint1)"
The 9 checkboxes are 9 constraints all in tblOne!Field1.
Public Sub Constraint2_AfterUpdate()
strColour = "Red"
Call IfStatement(strColour)
End Sub
Public Sub IfStatement(strColor As String)
If strSQL = "*WHERE*" Then
strSQL = strSQL & " AND (tblOne!Field1 = '" & strColor
& "')"
Else
strSQL = strSQL & " WHERE (tblOne!Field1 = '" &
strColor & "')"
End If
End Sub
Please help
Thanks
Hafeez Esmail
making a query for my users.
The users want to be able to view a query based what ever
constraints they select on the form (in the form of
checkboxes).
The base of the query is:
Set qdfTemp = CurrentDb.CreateQueryDef("qrySteveCustom",
strSQL)
strSQL starts off as:
strSQL = "SELECT * FROM tblOne"
strSQL
When the user checkmarks a box, strSQL gets updated and
will now read:
strSQL = strSQL & " WHERE (tblOne!Field1 = strConstraint1)"
The 9 checkboxes are 9 constraints all in tblOne!Field1.
Public Sub Constraint2_AfterUpdate()
strColour = "Red"
Call IfStatement(strColour)
End Sub
Public Sub IfStatement(strColor As String)
If strSQL = "*WHERE*" Then
strSQL = strSQL & " AND (tblOne!Field1 = '" & strColor
& "')"
Else
strSQL = strSQL & " WHERE (tblOne!Field1 = '" &
strColor & "')"
End If
End Sub
Please help
Thanks
Hafeez Esmail