hi.. i was wondering if anyone could look at my reportgenerator and tell me whats the problem with the code ... im trying to filter some stuf but it doesnt work.. its a report generator made in access
okej.. this is the thing.. i have three combo boxes... and i want to filter with these... this is the code to the first report that works...
Option Compare Database ' Use database order for string comparisons '
Option Explicit
Global RapString
Sub AddToWhere(FieldValue As Variant, FieldName As String, MyCriteria As String, Argcount As Integer, Argument As Variant)
If IsNull(FieldValue) Then Exit Sub
If FieldValue = "" Then Exit Sub
If (Left(FieldValue, 1) = "'" Or (Left(FieldValue, 1) = "#" Then
If Len(FieldValue) < 3 Then Exit Sub
End If
If Argcount > 0 Then MyCriteria = MyCriteria & " and "
Select Case Argument
Case "Like"
MyCriteria = (MyCriteria & FieldName & " Like " & Chr(39) & FieldValue & Chr(42) & Chr(42) & Chr(39))
Case Else
MyCriteria = (MyCriteria & FieldName & " " & Argument & " " & FieldValue)
End Select
Argcount = Argcount + 1
End Sub
Function HumanRecordsource(H_Severity, H_Freq, H_FreqTo, H_Risk)
Dim MySql As String, MyCriteria As String, MyRecordsource As String
Dim Argcount As Integer
Dim Tmp As Variant
Argcount = 0
MySql = "SELECT * From Human WHERE "
MyCriteria = ""
AddToWhere "'" & H_Severity & "'", "[Human_Severity_Class]", MyCriteria, Argcount, "="
If Not IsNull(H_Freq) Then AddToWhere "'" & H_Freq & "'", "[Human_Frequency]", MyCriteria, Argcount, ">="
If Not IsNull(H_FreqTo) Then AddToWhere "'" & H_FreqTo & "'", "[Human_Frequency]", MyCriteria, Argcount, "<="
AddToWhere "'" & H_Risk & "'", "[Risk_Class_Human]", MyCriteria, Argcount, "="
If MyCriteria = "" Then MyCriteria = "True"
HumanRecordsource = MySql & MyCriteria
RapString = MySql & MyCriteria
End Function
the second report is a crosstab query... but i want it to filter with these comob boxes also... and that doesnt work...how come?
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.