Results 1 to 2 of 2

Thread: Data Report Problem

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Nov 1999
    Location
    Muscatine, Iowa, USA
    Posts
    18

    Post

    Hi,
    I am trying to use parameters with DataReport. A friend gave an example of one that works. It is coded over the Nwind.mdb file. I made a few changes. I changed the SELECT statment to select for City rather the customer ID and I started getting the follow error mag.

    failed getting reowset(s) from current datasource.

    Here is the code with remarks showing where the problem occurs.

    Private Sub Search_Click()
    'The If block closes the recordset if it was previously open before
    'running the parameterized query.
    With DataEnvironment1
    If .rsCommand1.State = adStateOpen Then
    .rsCommand1.Close
    End If
    ' This passes in the value entered into the TextBox.
    .Command1 Text1.Text

    ' This If block checks to determine if any records are returned
    ' by the parameter. Then it shows a report if records are returned.
    ' Or displays a Message Box if no records are returned.

    If .rsCommand1.RecordCount > 0 Then
    ' Degbug shows a number of records in the data source
    Set DataReport2.DataSource = DataEnvironment1
    ' The Error is "Failed getting Rowset(s) from current data source"
    DataReport2.Show
    Else
    MsgBox "No Titles found" & Text1.Text
    End If
    End With
    End Sub

    Any help is appreciated.
    Thanks,
    Jim

  2. #2
    New Member
    Join Date
    Jan 2000
    Location
    Toronto,Canada
    Posts
    7

    Post

    button click event from other form
    DataReport2.Show


    'put this code in the reports initialize section

    Dim x As String
    Dim rscommand1 As ADODB.Command
    Set rscommand1 = New ADODB.Command
    x = Form1.command1.Text1.Text

    If Dataenvironment1.rscommand1.State = adStateOpen Then
    dataenvironment1.rscommand1.Close ' make sure the query is closed
    rscommand1.Cancel
    End If
    With DataReport1
    Set .DataSource = dataemvironment1
    .DataMember = "rscommand1"
    Dataenvironment1.command1 x
    End With

    you may have to fool around with this code but it works for me.


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