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!

7 hours with the same problem ???

Status
Not open for further replies.

CompGirl

Technical User
Jun 2, 2003
40
SE
i dont know what im doing wrong.. i have a form that will print out a report after choosing options in the combo boxes... then my filtering code is like this:

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



and this works when i want to print out a normal report... but now i have a report that i made through crosstab query... and yer supposed to print this out too through the combo boxes... but i cant get this to work.. this is the code from class object for the report

Private Sub Report_Open(Cancel As Integer)
Me.RecordSource = RapString

Dim I As Integer
For I = 0 To 7
ReportLabel(I) = &quot;&quot;
Next I
Call CreateReportQuery
End Sub

Sub CreateReportQuery()
On Error GoTo Err_CreateQuery
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim qdf As DAO.QueryDef
Dim fld As DAO.Field
Dim indexx As Integer
Dim FieldList As String
Dim strSQL As String
Dim I As Integer

Set db = CurrentDb
Set qdf = db.QueryDefs(&quot;ProCrosstab&quot;)
indexx = 0
For Each fld In qdf.Fields
If fld.Type >= 1 And fld.Type <= 8 Or fld.Type = 10 Then
FieldList = FieldList & &quot;[&quot; & fld.Name & &quot;] as Field&quot; & indexx & &quot;, &quot;
ReportLabel(indexx) = fld.Name
End If
' MsgBox Label(indexx)
indexx = indexx + 1
Next fld
For I = indexx To 7
FieldList = FieldList & &quot;null as Field&quot; & I & &quot;,&quot;
Next I
FieldList = Left(FieldList, Len(FieldList) - 2)

strSQL = &quot;Select &quot; & FieldList & &quot; From ProCrosstab&quot;

db.QueryDefs.Delete &quot;CrossTabReportP&quot;
Set qdf = db.CreateQueryDef(&quot;CrossTabReportP&quot;, strSQL)


Exit_CreateQuery:
Exit Sub

Err_CreateQuery:
If Err.Number = 3265 Then '*** if the error is the query is missing
Resume Next '*** then skip the delete line and resume on the next line
Else
MsgBox Err.Description '*** write out the error and exit the sub
Resume Exit_CreateQuery
End If
End Sub

Function FillLabel(LabelNumber As Integer) As String
FillLabel = Nz(ReportLabel(LabelNumber), &quot;&quot;)

End Function


am i supposed to make a whole new query?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top