Results 1 to 5 of 5

Thread: DataReport and ADODB Help!!!

  1. #1

    Thread Starter
    Member
    Join Date
    Aug 2007
    Posts
    37

    Resolved DataReport and ADODB Help!!!

    Hi. I'm in need of hepl.
    I have the following code for creating a report at runtime
    Code:
    Private Sub cmdRaport_Click() 
    
    Dim rs As New ADODB.Recordset
    Dim cn As ADODB.Connection
    Dim rap As New DataReport1
    Dim StrSQL As String
    
    Set cn = New ADODB.Connection
    cn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
            "Data Source= " & App.Path & "\db\Model.mdb"
    cn.Open
    
        StrSQL = "SELECT * FROM Hordere WHERE OrderID = " & ordID    
        Set rs = cn.Execute(StrSQL)
        
        'Header and Report caption
        With rap.Sections("RepHeader")
            .Controls("lblFirm").Caption = frmMain.mccFirma.Text
        End With
    '    rap.Caption = frmMain.cboOrder.Text
        
        rap.Sections("PgHeader").Controls("lblPH").Caption = "PROCES TEHNOLOGIC"
        
        With rap.Sections("ordHead")
            .Controls("lblOrd").Caption = "Order:"
            .Controls("lblMod").Caption = "Model:"
            .Controls("txtOrd").DataField = frmMain.cboOrder.Text
            .Controls("txtMod").DataField = frmMain.mccModClient.Text
        End With
        
        Set rap.DataSource = rs
        
        With rap.Sections("ordDet")
            .Controls("txtCod").DataField = "CodOP"
            .Controls("txtOp").DataField = "Operatii"
            .Controls("txtNMunc").DataField = "Nrmunc"
            .Controls("txtNT").DataField = "NT"
            .Controls("txtNP").DataField = "NP"
        End With
        
        rap.Show vbModal
        rs.Close
        Unload rap
        Set rs = Nothing
        Set rap = Nothing
    End Sub
    It works fine until it reaches "rap.Show vbModal" when it shows the report. I get an error message: DataFiled "Ord1" Not Found.
    Ord1 is the name of the order. What did i do wrong?

    Pls Help it's urgent

    Thanks and regards
    Addict

  2. #2
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974

    Re: DataReport and ADODB Help!!!

    Do you have a Field which is called Ord1?

    If not, you don't want to specify that as a DataField.. I presume you want to assign it to the Caption instead.

  3. #3

    Thread Starter
    Member
    Join Date
    Aug 2007
    Posts
    37

    Re: DataReport and ADODB Help!!!

    No i don't have Ord1 as a field. It's the name of the order bun it's not a field. And the interesting part is that i'm not asigning it as a field. "Ord1" is not in the table i'm creating the report for.

  4. #4
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974

    Re: DataReport and ADODB Help!!!

    I'm assuming that you are assigning it as a field in this section:
    Code:
    ...
            .Controls("lblMod").Caption = "Model:"
            .Controls("txtOrd").DataField = frmMain.cboOrder.Text
            .Controls("txtMod").DataField = frmMain.mccModClient.Text
    ...

  5. #5

    Thread Starter
    Member
    Join Date
    Aug 2007
    Posts
    37

    Re: DataReport and ADODB Help!!!

    Yes. I saw that 2 after i posted thanks for the help :P

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