DataReport form can't catch a var???
Hi all...
I'm sending along a var -- a string really -- to a DataReport page. Therein, I'll use it to check for a match in my Access dbase to run a record set.
The thing is, the DataReport form wont catch that var???
Here's the code...
Code:
sending the var here....
Private Sub cmdReport_Click()
taskName = cmbClientList.Text
' this makes the comboList current text name a var to pass to the Reports page...
Debug.Print "sending taskName as " & taskName
DataReport1.SetupRecord (clientName)
' send the app to the report form with proper vars already there...
DataReport1.Show
' show the report form
End Sub
and then this is the setup script on the DataReports form...
Code:
Public clientName As String
Public taskName As String
Public Sub SetupRecord(clientName)
On Error GoTo ErrHandler
Dim cnCater As ADODB.Connection
Dim rsCater As ADODB.Recordset
Dim sSql As String
Set cnCater = SetConnection
Set rsCater = SetRecordset
cnCater.Open
Dim strDate1 As String
strDate1 = frmMainPage.ReportStart.Value
' grab start date from DTPicker start
Dim strDate2 As String
strDate2 = frmMainPage.ReportEnd.Value
' grab end date from DTPicker end
Debug.Print "catching " & taskName
sSql = "SELECT [username], [name], item, [day], timein, timeout, totalhours, comments, rate, (rate * totalhours) AS totals FROM clients WHERE done = TRUE AND [name] = '" & taskName & "' AND [day] BETWEEN #" & strDate1 & "# AND #" & strDate2 & "#"
rsCater.Open sSql, cnCater, adOpenDynamic, adLockOptimistic
' open that rs with that sql string...
Set Me.DataSource = rsCater
' set the report to this datasource...
clientName = rsCater.Fields("username")
Me.Sections("section4").Controls("lblclientNameHolder").Caption = "for: " & clientName
' add personalization to top section here...
Me.Sections("section3").Controls("lbltaskName").Caption = "TASKNAME PASSED IS " & taskName
' testing to see what was passed along...so far NOTHING!!!
ErrHandler:
' MsgBox "Sorry, there are no records on any completed tasks within that timeframe!", vbExclamation
Exit Sub
End Sub
When it runs, and I select a client name --which properly shows up in the Immediate window, it never reaches the DataReports form....???
Help here guys, what am I missing?
Jim
Nope....that's not it yet either...
Ummm...
Tried that yesterday. Just did it again...and I've ensured that I typed it correctly etc.
But when I then select a name in the comboList...and then click on the command button to take me to the report...I get an error that says it's a compile error...it hilites the Sub cmdReport_Click()and points to this line...
DataReport1.SetupRecord (clientName,taskName)
Why is that? Since when can you only pass 1 var via an argument to a sub...even if it's on a dataReport?
Geez...now I'm really lost...
Jim