Run-Time Error

G

Guest

When running a report, i get an error

"Run-time error '-2147352567 (80020009)': You can't assign a value to this
object."

I have a text field, rptAlloy, and want to fill it with a field from a query
that filled from the form that generates the report...i.e. Form to view
data->click preview/print report->qyr runs->report is generated

here is the code for when the rpt opens up:

Private Sub Report_Open(Cancel As Integer)

Dim C1894db As Database
Dim rst As Recordset

Set C1894 = CurrentDb
Set rst = C1894.OpenRecordset("qryReport")

MsgBox (rst!Alloy)

Me.rptAlloy = rst!Alloy

End Sub

i have the MsgBox as a test, and the MsgBox comes up with the right entry,
however the textbox i want to store the value in won't accecpt the value.

any suggestions? (i have about 25-30 fields, and i wanted to keep the same
formatting as the form view, so i copied the form, and pasted it in the
report, but then "redrew everything from scratch...)
 
S

Stefan Hoffmann

hi Mike,
Private Sub Report_Open(Cancel As Integer)

Dim C1894db As Database
Dim rst As Recordset
Better:

Dim C1894db As DAO.Database
Dim rst As DAO.Recordset
Set C1894 = CurrentDb
The here used variable is undeclared as you declared C1894db (db at the
end).


mfG
--> stefan <--
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top