You Cant Assign a Value to the Object - Access Report (1 Viewer)

Ksabai

Registered User.
Local time
Today, 09:56
Joined
Jul 31, 2017
Messages
104
The Following is the code iam using to populate the text box tsOrigin

Public Sub repPopulate()
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim qdf As DAO.QueryDef
Dim prm As DAO.Parameter
Dim orig As String
Dim countrec As Integer

Set db = CurrentDb
Set qdf = db.QueryDefs("qryControllerDue")
For Each prm In qdf.Parameters
prm = Eval(prm.Name)
Next prm
Set rs = qdf.OpenRecordset(dbOpenDynaset)

With rs
rs.MoveFirst
Do Until rs.EOF
tSOrigin.Value = rs![InvNo]
rs.MoveNext
countrec = countrec + 1
Loop
End With

End Sub

i get the error at the line
tSOrigin.Value = rs![InvNo]
 

theDBguy

I’m here to help
Staff member
Local time
Today, 09:56
Joined
Oct 29, 2018
Messages
21,358
Hi. What is "tSOrigin?" Is it a Textbox? Which event are you using? Why are you using a recordset to populate the controls on a report? Just curious...
 

Ksabai

Registered User.
Local time
Today, 09:56
Joined
Jul 31, 2017
Messages
104
i want to populate different values in a single report that why iam using recordset. iam calling in open report
 

MajP

You've got your good things, and you've got mine.
Local time
Today, 12:56
Joined
May 21, 2018
Messages
8,463
First of all the code does not make any sense. Even if you could set the value, it would always get the value of the last record in the recordset.
 

Ksabai

Registered User.
Local time
Today, 09:56
Joined
Jul 31, 2017
Messages
104
simplest way is to create another report, but i don't want to do that
 

MajP

You've got your good things, and you've got mine.
Local time
Today, 12:56
Joined
May 21, 2018
Messages
8,463
Can you explain in words what you have and what you would like to get out. Can you just do an open report with a criteria with a docmd.openreport? Aren't the parameters filtering to a specific value?
 

theDBguy

I’m here to help
Staff member
Local time
Today, 09:56
Joined
Oct 29, 2018
Messages
21,358
i want to populate different values in a single report that why iam using recordset. iam calling in open report
Sorry, that doesn't make sense without seeing your db design. Are you saying you want the report to show data from different queries or tables?

Edit: Okay, it's "lunch break" over here, so I'll be gone for a while. Cheers!
 

Ksabai

Registered User.
Local time
Today, 09:56
Joined
Jul 31, 2017
Messages
104
Majp, i meant iam using at Report_Open(Cancel As Integer) section of the report
 

MajP

You've got your good things, and you've got mine.
Local time
Today, 12:56
Joined
May 21, 2018
Messages
8,463
You can pass in the rowsource query in the openargs but have to set it in the on open not the on load (too late)
Private Sub Report_Open(Cancel As Integer)
If Not Trim(Me.OpenArgs & " ") = "" Then
Me.RecordSource = Me.OpenArgs
End If
End Sub
 

Saphirah

Active member
Local time
Today, 17:56
Joined
Apr 5, 2020
Messages
163
Hey Ksabai, if you want to add parameters from different queries you can edit the form source property!
Just open your form in design view, property sheet -> form -> data and then edit the record source using the 3 dots. With right click on the big area you can add your tables and queries you need and then you can just double click the entrys you want. Then you can go to your TextBoxes you are using and add those values as a control source
 

Saphirah

Active member
Local time
Today, 17:56
Joined
Apr 5, 2020
Messages
163
I know it is annoying that you can not use labels but textboxes work fine. If you do not want the user to be able to edit the values you can set the enabled property to false and the locked property to true.
Cheers
 

Users who are viewing this thread

Top Bottom