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. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
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
|
|||
|
|||
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
|
|||
|
|||
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
|
|||
|
|||
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 | |
|
|
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 |