Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

You Cannot Assign a Value to this object 1

Status
Not open for further replies.

cranebill

IS-IT--Management
Jan 4, 2002
1,113
US
I have been at this for a little while now... anyone have any ideas? Here is the code...

Option Compare Database

Private Sub Report_Open(Cancel As Integer)
Dim db As Database
Dim rs As Recordset
Dim Date1 As Date
Dim Date2 As Date
Dim CompanyID As Long
Dim dt As Date

CompanyID = [Forms]![Main Menu]![Customer ID]
dt = Date

Set db = CurrentDb()

Set rs = db.OpenRecordset(&quot;SELECT TOP 2 InspectionTable.InspectionID, InspectionTable.CompanyID, InspectionTable.DateOf FROM InspectionTable WHERE (((InspectionTable.CompanyID)= &quot; & CompanyID & &quot;) AND ((InspectionTable.DateOf)< #&quot; & dt & &quot;#)) ORDER BY InspectionTable.InspectionID DESC;&quot;)


Date1 = rs!DateOf
rs.MoveNext
Date2 = rs!DateOf

Me!InspectionDate = Date1

rs.Close
Set rs = Nothing
Set db = Nothing

End Sub

Me!InspectionDate = Date1 (this is where the error lies)

Inspection Date is nothing more than an unbound textbox on a report....

Any help would be greatly appreciated.

Bill
 
I usually get that nondescript error when someone (user) or something (procedure) has the object busy at the time.
 
Well the code runs when the report first opens and right now this is running only on my machine till i get the bugs worked out so noone else has &quot;Access&quot; ( a lil humor) to it at this point.

Bill
 
Hi Cranebill,

If memory serves me correctly, you can not make changes to a report once the report has started the opening process. It would have be to set at the record source level prior to the open event firing.

Now, forms on the other hand, can have values set/changed/added. Reports dont act the same way.

at a guess from looking at your code, if you tried your code in a Form, it would work.

Have A Great Day!!!,

Nathan
Senior Test Lead
 
If I understand your problem correctly, you would need to set the value in the appropriate format section of the report, not on open

ie: if the text box is in the detail section then set the value in the detail format event
Terry (cyberbiker)
 
Thank You for all the help... cyberbiker is correct though, upon putting the code in the format detail section instead of the on open... works like a charm.

Bill
 
Yep,

I stand corrected. :) I tried it this morning and it worked fine.

Thanks CyberBiker!!!

Have A Great Day!!!,

Nathan
Senior Test Lead
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top