Results 1 to 9 of 9

Thread: DataReport form can't catch a var???

  1. #1

    Thread Starter
    Addicted Member JVRudnick's Avatar
    Join Date
    Oct 2001
    Location
    Toronto, Canada
    Posts
    135

    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
    Jim Rudnick
    MCSD
    KKT INTERACTIVE
    www.kkti.com

  2. #2
    Fanatic Member
    Join Date
    Aug 2001
    Location
    Connecticut
    Posts
    855
    Debug.Print "sending taskName as " & taskName
    DataReport1.SetupRecord (clientName)

    So, how is the data report going to get taskname?
    Setuprecord passes only clientname.
    If you intend to pass it directly on account of the report declaration:
    Public taskName As String
    then it's
    Datarepot1.taskname = cmbClientList.Text
    VB 6.0, Access, Sql server, Asp

  3. #3

    Thread Starter
    Addicted Member JVRudnick's Avatar
    Join Date
    Oct 2001
    Location
    Toronto, Canada
    Posts
    135

    Hmmm...

    Okay, I copied that line and pasted it inside the Setup sub...

    And now when I choose a name from the comboList, I get an error that says --

    Compile Error -- Variable not Defined

    and it points at this line in the DataReport

    Public Sub SetupRecord(clientName)


    ???


    Jim
    Jim Rudnick
    MCSD
    KKT INTERACTIVE
    www.kkti.com

  4. #4
    Fanatic Member
    Join Date
    Aug 2001
    Location
    Connecticut
    Posts
    855
    Hi,
    I meant this in the:
    Sub cmdReport_Click()
    Datareport1.taskname = cmbClientList.Text
    DataReport1.SetupRecord (clientName)
    DataReport1.Show
    end sub

    Incidentally, I had originally mispelled Datareport1.
    VB 6.0, Access, Sql server, Asp

  5. #5

    Thread Starter
    Addicted Member JVRudnick's Avatar
    Join Date
    Oct 2001
    Location
    Toronto, Canada
    Posts
    135

    Still only close...

    Just tried that, and while I now get no runtime errors etc.....

    The taskName is STILL not passed along. It does not appear in either the debug.print item nor even the label I've got on the report form itself...

    So...what else might be doing this? I've already shown the total code for the report above...

    Any other ideas?

    Jim
    Jim Rudnick
    MCSD
    KKT INTERACTIVE
    www.kkti.com

  6. #6
    Fanatic Member
    Join Date
    Aug 2001
    Location
    Connecticut
    Posts
    855
    Ok, I tried this instead and it works. Simply Pass taskname in the function
    Sub cmdReport_Click()
    ....
    DataReport1.SetupRecord (clientName, taskname)
    etc
    end sub

    in the report:
    Public Sub SetupRecord(clientName, taskname)
    etc.
    VB 6.0, Access, Sql server, Asp

  7. #7

    Thread Starter
    Addicted Member JVRudnick's Avatar
    Join Date
    Oct 2001
    Location
    Toronto, Canada
    Posts
    135

    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
    Jim Rudnick
    MCSD
    KKT INTERACTIVE
    www.kkti.com

  8. #8
    Fanatic Member
    Join Date
    Aug 2001
    Location
    Connecticut
    Posts
    855
    It's simply due to vb's damn loose syntax rules that we're forgetting about. Leave out the parantheses for subs:
    DataReport1.SetupRecord clientName, taskName
    Or
    Call DataReport1.SetupRecord (clientName,taskName)

    I just discovered (experimenting) that vb allows parantheses if it's only one argument:
    DataReport1.SetupRecord (clientName)
    but not with two:
    DataReport1.SetupRecord (clientName,taskName)

    Stupid, isn't it?

    VB 6.0, Access, Sql server, Asp

  9. #9

    Thread Starter
    Addicted Member JVRudnick's Avatar
    Join Date
    Oct 2001
    Location
    Toronto, Canada
    Posts
    135

    Bingo!

    thanks Ralph...

    that's an odd one...

    I'm gonna try and go back later today, and see if I've done that kind of double or triple passing of args before using ()....

    Seems to me I have....but I'll post my findings here....

    And thanks...code runs fine now!

    Jim
    Jim Rudnick
    MCSD
    KKT INTERACTIVE
    www.kkti.com

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width