473,405 Members | 2,349 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

Vb. Open report error based on a form that is just opened.

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.

Expand|Select|Wrap|Line Numbers
  1. DoCmd.Openform "FrmPrice"
  2. DoCmd.Openreport "ReportOffer"
Tried to put me.Requery. Didn't help.
Please help... Thanks
*Access 2007
Nov 24 '14 #1
8 1418
Seth Schrock
2,965 Expert 2GB
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?
Nov 24 '14 #2
Yes, correct. It works OK if I open the report AFTER the form is fully opened.
Nov 25 '14 #3
twinnyfo
3,653 Expert Mod 2GB
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.
Nov 25 '14 #4
Seth Schrock
2,965 Expert 2GB
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.
Nov 25 '14 #5
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
Nov 27 '14 #6
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:

Expand|Select|Wrap|Line Numbers
  1. While Forms!FrmPrice!ctrlXxx = 0
  2.    DoEvents
  3. 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.
Nov 27 '14 #7
twinnyfo
3,653 Expert Mod 2GB
Eddie,

Glad you found a solution that worked.!
Dec 1 '14 #8
Thanks for your attention. Appreciate it.
Dec 1 '14 #9

Sign in to post your reply or Sign up for a free account.

Similar topics

3
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...
16
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...
2
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...
12
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,...
4
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...
5
reginaldmerritt
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...
4
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...
1
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...
4
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...
0
BarryA
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
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...
0
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...
0
Oralloy
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,...
0
jinu1996
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...
0
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...
0
agi2029
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,...
0
isladogs
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...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.