My Assistant
![]() ![]() |
|
|
Aug 2 2009, 07:07 AM
Post
#1
|
|
|
UtterAccess Member Posts: 34 From: Anglesey, United Kingdom |
Hello - I want to set the RecordSource property of a report dynamically but am having problems getting it right. I have a list box in a form - the content changes depending of which command button is pressed. I do this with the code: lstNamesAddress.Rowsource = "qryABC" - in the OnClick event for each command button.
I then want to print the contents of the list box so I have a report that has this line of code in the OnOpen event to change the source: Report!rptNamesAddress.Recordsource = "qryABC" - this fails with the error "Access can't find the field rtpNamesAddress". I'm probably making a basic mistake but can't see what it is! - Any help much apprciated Kind regards |
|
|
|
Aug 2 2009, 07:26 AM
Post
#2
|
|
|
UtterAccess VIP Posts: 7,646 From: South coast, England |
Hi Kevin
You need to change the code in the reports on open event to: Me.RecordSource = "qryABC" (using a dot not the bang as it implies a field rather than property of the report) HTH |
|
|
|
Aug 2 2009, 07:29 AM
Post
#3
|
|
|
UtterAccess Editor Posts: 13,813 From: England (North East / South Yorks) |
Hi, nicer day isn't it? (Thankfully - soggy day in the garden :-s)
In the report event procedure you can simply use the Me keyword Me.Recordsource = "qryABC" for the full syntax you need Reports!rptNamesAddress.Recordsource = "qryABC" As just Report refers to the current Report object (analogously to Me). Hence why you get the failed reference to a field using just Report. Cheers. |
|
|
|
Aug 2 2009, 07:40 AM
Post
#4
|
|
|
UtterAccess Member Posts: 34 From: Anglesey, United Kingdom |
I knew it was obvious!!
Many thanks to you both, Kevin |
|
|
|
Aug 2 2009, 09:41 AM
Post
#5
|
|
|
UtterAccess VIP Posts: 7,646 From: South coast, England |
You're welcome, Leigh and I are always pleased to help (IMG:http://www.utteraccess.com/forum/style_emoticons/default/thumbup.gif)
Good luck with your project. Leigh - thanks for correcting 'Reports!rptNamesAddress.Recordsource' - I should have paid more attention (IMG:http://www.utteraccess.com/forum/style_emoticons/default/blush.gif) |
|
|
|
![]() ![]() |
|
Go to Top · Lo-Fi Version | Time is now: 19th June 2013 - 03:25 PM |