I have a main form, FrmMain. Put a button to open "FrmPrice". Works OK. In FrmPrice I put another button that open a report, ReportOffer, based on FrmPrice. Works OK too.
I tried to put a button in FrmMain to directly open FrmPrice and then open ReportOffer, the code failed in calculated control with #error. - DoCmd.Openform "FrmPrice"
-
DoCmd.Openreport "ReportOffer"
Tried to put me.Requery. Didn't help.
Please help... Thanks
*Access 2007
8 1418
When you say you open ReportOffer based on FrmPrice, what do you mean? Do you have to enter/select a value for a control in FrmPrice that has to do with the calculated field in ReportOffer?
Yes, correct. It works OK if I open the report AFTER the form is fully opened.
Eddie,
I believe the problem comes that you are trying to open the two objects essentially simultaneously. If ReportOffer only runs after FrmPrice is opened, you must actually wait until the form fully loads before the report can use any data on that Form.
Seth, do you know of a way to check the Form's load status programmatically? If not, I think one way would be to send a value to the Form and in the OnLoad event of the Form, if that value is True, to open the Report, otherwise, wait for the user to click the button.
This is one of the challenges with using Form values as part of a Record Source for any other object in Access--it is not a "wrong" process, but there are several challenges you must be careful for, and this is one of them.
My guess is that the value in FrmPrice isn't getting entered/selected and thus it's not available for the report. One option would be to move the control from FrmPrice to FrmMain and that would eliminate the step of opening FrmPrice. Another option would be to open FrmPrice as a Dialog Box which stops code execution in the calling form until it closes, which would allow you to select the value necessary for the calculation of the report. Or you could use code to set the value in FrmPrice before you open the report.
However, I don't believe that the problem is that the report is opening before the form is completely open. I have coded many times where I set a control value immediately after using the DoCmd.OpenForm command. This wouldn't work if the form hadn't finished opening. I think that the control is empty when the report is calling for it, meaning the user hasn't supplied the value.
Yes, the control is empty when the report is opened. Hence the error. Tried the acDialog, but I couldn't get it to work (open the report without closing the form). Thanks anyway
Thank you all... Solved the issue. In the main form I write DoCmd.OpenForm "FrmPrice". Below this line I wait for the control in the opened FrmPrice to get its value: - While Forms!FrmPrice!ctrlXxx = 0
-
DoEvents
-
Wend
Then the open report command line. It works.
Thanks again...
I had used the DoEvents before, but without waiting for the control to get its value.
Eddie,
Glad you found a solution that worked.!
Thanks for your attention. Appreciate it.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Douglas Buchanan |
last post by:
Buttons don't work if form is opened on startup
A2k
If 'frmMain' is set to open by default at startup none of the buttons
work.
If 'frmMain' is opened from the database window then all the...
|
by: iwdu15 |
last post by:
hi, i have a few forms in my project. when i load form1 (startup for) all is
fine, then i open another one and use a login screen to call yet another and
all is still fine, but then when i try to...
|
by: Miguel |
last post by:
I have reviewed the many postings on this topic and understand the
principle, but am not sure where in my case to apply trapping an error.
I have created a form to supply parameters to a report. I...
|
by: Orchid |
last post by:
Hello all,
I have different version of reports which used for different months.
For example, I am using report version 1 up to September, but we have
some design changes on the report for October,...
|
by: Peter |
last post by:
Access 2007 optionally opens forms as tabs. There is an Access Option
that controls this - Access Options Current Database Document
Window Options Tabbed Documents.
But how, from VBA, can I...
|
by: reginaldmerritt |
last post by:
Hello
I'm creating a database application to manage our training centre. This includes registering candidates on courses\programmes.
I have a table (‘registrations’) that holds this information...
|
by: Phil Stanton |
last post by:
I am opening a report (in Preview) from a menu system
I use the following code if there is no data in a report
Private Sub Report_NoData(Cancel As Integer)
MsgBox "There are no errors in...
|
by: slenish |
last post by:
Hello everyone,
I am having an issues with a report. I have created a date field on a report that is unbound. I have a form that you use to open the report. On the form you enter in a date range...
|
by: joseppi01 |
last post by:
Hi there
I don't have a lot of programming experience (apart from google searching everything and a bit in Crystal) but Access just throws me!
I'm trying to link a record from a report to the...
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
| |