|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
I'm looking for help on a solution to use comparison operators (<, >, <>, <=, and >=, =) as variables in a query for a report. What I'm doing presently is using a form with combo boxes to select criteria for a SQL string to query a report.
I would like to add the capability to also choose(cmbobox) an operator and compare it to a number entered into a text box; Adding this comparison to the SQL String for the query. If anybody has a solution or a better way of doing it, I would appreciate it greatly. I'm presently using the code: Private Sub cmdSetFilter_Click() Dim strSQL As String, intCounter As Integer 'Build SQL String For intCounter = 1 To 6 If Me("Filter" & intCounter) <> "" Then strSQL = strSQL & "[" & Me("Filter" & intCounter).TAG & "] " & _ " = " & Chr(34) & Me("Filter" & intCounter) & Chr(34) & " And " End If Next If strSQL <> "" Then 'Strip Last " And " strSQL = Left(strSQL, (Len(strSQL) - 5)) 'Set the Filter property Reports![Assets Query].Filter = strSQL Reports![Assets Query].FilterOn = True Else Reports![Assets Query].FilterOn = False End If End Sub |
|
#2
|
|||
|
|||
|
Ericed
Try this Dim varOper As Variant varOper = [OperatorComboBox] strSQL = strSQL & "[" & Me("Filter" & intCounter).TAG & "] " & _ varOper & Chr(34) & Me("Filter" & intCounter) & Chr(34) & " And " lwells |
|
#3
|
|||
|
|||
|
Quote:
I have 20 combo boxes and i typed in the same SQL text as you to get a filter based on the report but i could only get it work for one combo box. How did you get yours to work on all of your combo boxes? I would be grateful of any help, thanks. |
|
#4
|
|||
|
|||
|
Microsoft has an example of this feature that I used at:
http://support.microsoft.com/kb/q208529/ It explains everything, and also has a link to the sample database "RptSmp00.mdb" along with other examples on how use reports. |
|
#5
|
|||
|
|||
|
Quote:
I have thought of using "varOper" like variable entrys in the SQL string, but since a string is continuously added to the prior string I end up with a faulty statement and data. What I mean by this is; if I want to filter multiple cmbox's with filter criteria like: = Department = Name >= CPU I end up with for my SQL String is: >= Department >= Name >= CPU |
![]() |
| Viewing: Dev Articles Community Forums > Databases > Microsoft Access Development > Parameter query using comparison operators as variables. |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|