PDA

Click to See Complete Forum and Search --> : DataReport and ADODB Help!!!


JazzAddict
Nov 2nd, 2007, 06:21 AM
Hi. I'm in need of hepl.
I have the following code for creating a report at runtime

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

si_the_geek
Nov 2nd, 2007, 06:28 AM
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.

JazzAddict
Nov 2nd, 2007, 06:31 AM
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.

si_the_geek
Nov 2nd, 2007, 06:37 AM
I'm assuming that you are assigning it as a field in this section:
...
.Controls("lblMod").Caption = "Model:"
.Controls("txtOrd").DataField = frmMain.cboOrder.Text
.Controls("txtMod").DataField = frmMain.mccModClient.Text
...

JazzAddict
Nov 2nd, 2007, 06:39 AM
Yes. I saw that 2 after i posted thanks for the help :P