Help with assignment of values to controls on report

A

Ayo

I am trying to assign value on a txtbox control from a form to a txtbox
control on a report.
Form txtbox control:txtBeginDateRange
Report txtbox control:txtStartDate

reportName = "Report by DR and Vendor"

I am have a problem with this line of code
Reports![reportName]!txtStartDate = Me.txtBeginDateRange

DoCmd.OpenReport reportName, acViewPreview

Any help will be appreciated. Thank you.
Ayo.
 
A

Allen Browne

You cannot assign a value to a text box on a report like that.

Instead, set the Control Source of the text box on the report so it reads
from the form, e.g.:
=Forms!Form1!txtBeginDateRange
 
A

Ayo

Thanks

Allen Browne said:
You cannot assign a value to a text box on a report like that.

Instead, set the Control Source of the text box on the report so it reads
from the form, e.g.:
=Forms!Form1!txtBeginDateRange

--
Allen Browne - Microsoft MVP. Perth, Western Australia

Reply to group, rather than allenbrowne at mvps dot org.

Ayo said:
I am trying to assign value on a txtbox control from a form to a txtbox
control on a report.
Form txtbox control:txtBeginDateRange
Report txtbox control:txtStartDate

reportName = "Report by DR and Vendor"

I am have a problem with this line of code
Reports![reportName]!txtStartDate = Me.txtBeginDateRange

DoCmd.OpenReport reportName, acViewPreview

Any help will be appreciated. Thank you.
Ayo.
 
A

Ayo

This doesn't work for the txtbox in the Report Header. I teid this
Private Sub Report_Open(Cancel As Integer)
Me.txtReportTitle = OpenArgs
End Sub

and this
=Forms![Invoice by Dates]!lblTitle.Value

doesn't work either. Any ideas?
Thanks

Allen Browne said:
You cannot assign a value to a text box on a report like that.

Instead, set the Control Source of the text box on the report so it reads
from the form, e.g.:
=Forms!Form1!txtBeginDateRange

--
Allen Browne - Microsoft MVP. Perth, Western Australia

Reply to group, rather than allenbrowne at mvps dot org.

Ayo said:
I am trying to assign value on a txtbox control from a form to a txtbox
control on a report.
Form txtbox control:txtBeginDateRange
Report txtbox control:txtStartDate

reportName = "Report by DR and Vendor"

I am have a problem with this line of code
Reports![reportName]!txtStartDate = Me.txtBeginDateRange

DoCmd.OpenReport reportName, acViewPreview

Any help will be appreciated. Thank you.
Ayo.
 
A

Allen Browne

Remove the code.

You can't have a text box bound to an expression, and then set it
programmatically as well.

--
Allen Browne - Microsoft MVP. Perth, Western Australia

Reply to group, rather than allenbrowne at mvps dot org.

Ayo said:
This doesn't work for the txtbox in the Report Header. I teid this
Private Sub Report_Open(Cancel As Integer)
Me.txtReportTitle = OpenArgs
End Sub

and this
=Forms![Invoice by Dates]!lblTitle.Value

doesn't work either. Any ideas?
Thanks

Allen Browne said:
You cannot assign a value to a text box on a report like that.

Instead, set the Control Source of the text box on the report so it reads
from the form, e.g.:
=Forms!Form1!txtBeginDateRange

Ayo said:
I am trying to assign value on a txtbox control from a form to a txtbox
control on a report.
Form txtbox control:txtBeginDateRange
Report txtbox control:txtStartDate

reportName = "Report by DR and Vendor"

I am have a problem with this line of code
Reports![reportName]!txtStartDate = Me.txtBeginDateRange

DoCmd.OpenReport reportName, acViewPreview

Any help will be appreciated. Thank you.
Ayo.
 
A

Ayo

I wasn't using the code and the expression together. I tried one and when it
didn't work I tried the other.

Allen Browne said:
Remove the code.

You can't have a text box bound to an expression, and then set it
programmatically as well.

--
Allen Browne - Microsoft MVP. Perth, Western Australia

Reply to group, rather than allenbrowne at mvps dot org.

Ayo said:
This doesn't work for the txtbox in the Report Header. I teid this
Private Sub Report_Open(Cancel As Integer)
Me.txtReportTitle = OpenArgs
End Sub

and this
=Forms![Invoice by Dates]!lblTitle.Value

doesn't work either. Any ideas?
Thanks

Allen Browne said:
You cannot assign a value to a text box on a report like that.

Instead, set the Control Source of the text box on the report so it reads
from the form, e.g.:
=Forms!Form1!txtBeginDateRange

I am trying to assign value on a txtbox control from a form to a txtbox
control on a report.
Form txtbox control:txtBeginDateRange
Report txtbox control:txtStartDate

reportName = "Report by DR and Vendor"

I am have a problem with this line of code
Reports![reportName]!txtStartDate = Me.txtBeginDateRange

DoCmd.OpenReport reportName, acViewPreview

Any help will be appreciated. Thank you.
Ayo.
 
A

Allen Browne

If you use the Control Source approach, the form must remain open.

You cannot assign a value to a control in Report_Open. The Format event of
the Report Header section is the first opportunity that works.

It is not clear how you are passing the value to OpenArgs. This works only
in later versions.

You have not indicated what error messages you are getting.

Add a Debug.Print to indicate whether the event is even firing.

--
Allen Browne - Microsoft MVP. Perth, Western Australia

Reply to group, rather than allenbrowne at mvps dot org.

Ayo said:
I wasn't using the code and the expression together. I tried one and when
it
didn't work I tried the other.

Allen Browne said:
Remove the code.

You can't have a text box bound to an expression, and then set it
programmatically as well.

Ayo said:
This doesn't work for the txtbox in the Report Header. I teid this
Private Sub Report_Open(Cancel As Integer)
Me.txtReportTitle = OpenArgs
End Sub

and this
=Forms![Invoice by Dates]!lblTitle.Value

doesn't work either. Any ideas?
Thanks

:

You cannot assign a value to a text box on a report like that.

Instead, set the Control Source of the text box on the report so it
reads
from the form, e.g.:
=Forms!Form1!txtBeginDateRange

I am trying to assign value on a txtbox control from a form to a
txtbox
control on a report.
Form txtbox control:txtBeginDateRange
Report txtbox control:txtStartDate

reportName = "Report by DR and Vendor"

I am have a problem with this line of code
Reports![reportName]!txtStartDate = Me.txtBeginDateRange

DoCmd.OpenReport reportName, acViewPreview

Any help will be appreciated. Thank you.
Ayo.
 

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