A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Setting Up & Running Reports
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Setting TextBox value based on WhereCondition value:



 
 
Thread Tools Display Modes
  #1  
Old April 4th, 2005, 09:58 AM
external usenet poster
 
Posts: n/a
Default Setting TextBox value based on WhereCondition value:

Hello,

I have read a lot of previous emails that relate to this issue but
still can't figure out how to do this (which should be possible because
it seems like such a common usecase):

I am opening a Report using VBA from my Visual Basic application using
the DoCmd.OpenReport function. Basically the user builds the
'whereCondition' graphically in the VB app and this is passed onto the
Report in the whereCondition.

Now on the Report there is a TextBox which should be populated with one
of the parameter values in the whereCondition (I get this value after
some nasty splitting). However, I am unable to get the Filter value in
the Report_Open event method (as I have read from some previous posts,
this is a Microsoft 'feature').

So the next logical thing for me to do was to put it in the
PageHeaderSection_Format method but even though we have the Filter
value, it is too late to set the TextBox ControlSource by that time!

Basically this doesn't work:

Private Sub PageHeaderSection_Format(Cancel As Integer, FormatCount As
Integer)
fltr = Me.Report.Filter
tokens = Split(fltr, "#")
monthYearDt = tokens(1)
Me.MonthYearVal.ControlSource = "=#" + monthYearDt + "#"
End Sub

It gives me the following error:
"You can't set the ControlSource property in Print Preview or after
printing has started..."

Can someone please point me in the right direction?

Thank you.

  #2  
Old April 4th, 2005, 02:51 PM
Duane Hookom
external usenet poster
 
Posts: n/a
Default

You can try set the Value rather than the Control Source.
Me.MonthYearVal.Value = "=#" & monthYearDt & "#"
Make sure that MonthYearVal text box doesn't have a control source.
--
Duane Hookom
MS Access MVP
--

wrote in message
ps.com...
Hello,

I have read a lot of previous emails that relate to this issue but
still can't figure out how to do this (which should be possible because
it seems like such a common usecase):

I am opening a Report using VBA from my Visual Basic application using
the DoCmd.OpenReport function. Basically the user builds the
'whereCondition' graphically in the VB app and this is passed onto the
Report in the whereCondition.

Now on the Report there is a TextBox which should be populated with one
of the parameter values in the whereCondition (I get this value after
some nasty splitting). However, I am unable to get the Filter value in
the Report_Open event method (as I have read from some previous posts,
this is a Microsoft 'feature').

So the next logical thing for me to do was to put it in the
PageHeaderSection_Format method but even though we have the Filter
value, it is too late to set the TextBox ControlSource by that time!

Basically this doesn't work:

Private Sub PageHeaderSection_Format(Cancel As Integer, FormatCount As
Integer)
fltr = Me.Report.Filter
tokens = Split(fltr, "#")
monthYearDt = tokens(1)
Me.MonthYearVal.ControlSource = "=#" + monthYearDt + "#"
End Sub

It gives me the following error:
"You can't set the ControlSource property in Print Preview or after
printing has started..."

Can someone please point me in the right direction?

Thank you.



  #3  
Old April 6th, 2005, 05:02 PM
zman
external usenet poster
 
Posts: n/a
Default

Thanks.

This works. I had already tried what you said but MonthYearVal had a
control source so it would not let me set the value.

As an aside, I discovered the OpenArgs param while ploughing through
these forums and I'm using that instead of the whereCondition.

  #4  
Old April 6th, 2005, 06:04 PM
Duane Hookom
external usenet poster
 
Posts: n/a
Default

OpenArgs are a fairly recent addition to Access Reports. Glad to hear you
found this solution.

--
Duane Hookom
MS Access MVP
--

"zman" wrote in message
oups.com...
Thanks.

This works. I had already tried what you said but MonthYearVal had a
control source so it would not let me set the value.

As an aside, I discovered the OpenArgs param while ploughing through
these forums and I'm using that instead of the whereCondition.



 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Setting the Control source of a textbox to a query based on the valueof another textbox on the same form Joey Running & Setting Up Queries 1 January 26th, 2005 03:35 AM
Office 2003 installation problem, log file attached.... Ryan Setup, Installing & Configuration 0 January 20th, 2005 06:57 PM
Setting default value in textbox field on form Christian Using Forms 5 January 16th, 2005 07:13 AM
Unable to save a security setting Eric Lommatsch Installation & Setup 0 May 12th, 2004 11:51 PM


All times are GMT +1. The time now is 11:55 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.