Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

:( reportgenerator

Status
Not open for further replies.

CompGirl

Technical User
Jun 2, 2003
40
SE
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
 
well it'd be more helpful if you pasted your code here...

Transcend
[gorgeous]
 
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 & &quot; and &quot;
Select Case Argument
Case &quot;Like&quot;
MyCriteria = (MyCriteria & FieldName & &quot; Like &quot; & Chr(39) & FieldValue & Chr(42) & Chr(42) & Chr(39))
Case Else
MyCriteria = (MyCriteria & FieldName & &quot; &quot; & Argument & &quot; &quot; & 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 = &quot;SELECT * From Human WHERE &quot;
MyCriteria = &quot;&quot;

AddToWhere &quot;'&quot; & H_Severity & &quot;'&quot;, &quot;[Human_Severity_Class]&quot;, MyCriteria, Argcount, &quot;=&quot;
If Not IsNull(H_Freq) Then AddToWhere &quot;'&quot; & H_Freq & &quot;'&quot;, &quot;[Human_Frequency]&quot;, MyCriteria, Argcount, &quot;>=&quot;
If Not IsNull(H_FreqTo) Then AddToWhere &quot;'&quot; & H_FreqTo & &quot;'&quot;, &quot;[Human_Frequency]&quot;, MyCriteria, Argcount, &quot;<=&quot;
AddToWhere &quot;'&quot; & H_Risk & &quot;'&quot;, &quot;[Risk_Class_Human]&quot;, MyCriteria, Argcount, &quot;=&quot;

If MyCriteria = &quot;&quot; Then MyCriteria = &quot;True&quot;
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?
 
thats why i thought it is easier if i send the generator so u can see directly...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top