Problem Passing and displaying Variables between forms

Massamiya

Registered User.
Local time
Tomorrow, 04:54
Joined
Jan 28, 2011
Messages
16
Hey guys, I am really a novice in VBA and would appreciate
If you could help me with a problem I am having with regards
To passing data between 2 unlinked forms in an Access 2003 databases
I am writing an Estimation program and have 2 forms the
General Spec Form named “frm_EstSpec” on which there are 40 text boxes,Several combo boxes and a command Button to run the Cost Estimationform (frm_EstCost).
I have created global variables in the standard modules to hold data that is passed back and forth the Cost estimation form “frm_EstCost” where the estimate is calculated and saved. I want to display the Estimation No, Cost and a few other data being held in the global variables on the General Spec form “frm_EstSpec” when focus returns to it but don’t know which event to trap it.
and display the data on the form.
I have tried Me.Requery in the current event of the form and after the code in the Command button calling the “frm_EstCost” form but without success.
I don’t know what the problem might be, please help me.

On the command button to execute the Cost Estimation form
I pass of data to the global variables like
PMachModel = Me!MachModel
PMachSize = Me!MachSize
PEstNo = “ “ ‘ the number is created in the cost Estimation form
And when the Save button is clicked on the Cost Estimation form
PMachModel = Me!CMachModel
PMachSize = Me!CMachSize
PEstNo = Me!EstNo

I need to know which event to use to capture the variables and show on the
General Spec Form frm_EstSpec
Me!MachModel = PMachModel
Me!MachSize = PMachSize
Me!EstNo= PEstNo

Don’t know whether it will help both forms are not modal, when I click on the command
button the Cost estimation form “frm_EstCost” just springs up while the general Spec form becomes invisible and when I click the END command button on the form
“frm_EstCost” the form the spec form “frm_EstSpec” is visible once more.
Thanks for devoting time to my problem.

Massamiya
 
Last edited:
Thanks John, I have tried the Form's On Got Focus event without
any success.
The Before Update displayed data after the "Save Command button"
was pressed which is too late.
 
Are you sure that the value has been committed to the variable at the time you are changing focus between your two forms?
 
Are you sure that the value has been committed to the variable at the time you are changing focus between your two forms?
Yes, the value is committed to the variable in the routine of the
"Save Command" button of the cost estimation form "frm_EstCost"
like this
PMachModel = Me!CMachModel
PMachSize = Me!CMachSize
PEstNo = Me!EstNo
 
If the value has been committed to the variable. I'm not sure why the Form's On Got Focus event does not work for you :confused:
 
If the value has been committed to the variable. I'm not sure why the Form's On Got Focus event does not work for you :confused:
The On Got Focus event doesn't run after the form "frm_EstSpec" regains
focus. I ran it in debug mode and the On Got Focus event never fired.
I don't really know why.
when I close the "frm_EstCost" form using the command DoCmd.Close
and focus returns to the "frm_EstSpec" form there seem to be no focus
on the form, I have to click on a control to set focus.
At the moment I can't find a means to set focus on a text box or any other control on the form programmatically.
I have tried almost all events on the form event list without any success
and don't know what next to do or try.
 
OnFocus does not fire for a form, if the form contains controls capable of receiving focus. Try OnActivate
 
As part of the code you are using to close the first form, trying putting a line that forces focus back to the second form;
Code:
Forms!SecondFormName!AnyControlOnThatForm.SetFocus
 
OnFocus does not fire for a form, if the form contains controls capable of receiving focus. Try OnActivate
The On Activate event did the trick.
Thanks very much. you and John have been a life saver.
More grease to your elbows.
 

Users who are viewing this thread

Back
Top Bottom