Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Code to simulate pressing F9 key 1

Status
Not open for further replies.

DomFino

IS-IT--Management
Jul 9, 2003
278
US
Hi everyone,
I have a main form (frmMaster) that opens and then opens a hidden form (frmCalculations)that holds a bunch of calculations. On frmMaster I have a command button that opens anther form (frmHourandSalary), which takes data from the main form, populates some fields on the newly opened frmHourlySalary and then performs a buch of calculations.

The Problem is that when the frmHourlySalary opens with the data, I must hit the F9 key to have the calculations update. I tried the DoCmd.Requery but it has no affect.

Is there a way to simulate the pressing of the F9 key with code?

Here is the code I have behind the main form button:

Code:
Private Sub cmdSalary_Click()
On Error GoTo Err_cmdSalary_Click

    Dim stDocName As String
    Dim stLinkCriteria As String
    
    stDocName = "frmHourandSalary"
    
    stLinkCriteria = "[tblMaster.MasterID]=" & Me![txtMasterID]
    DoCmd.OpenForm stDocName, , , stLinkCriteria
    DoCmd.Requery

Exit_cmdSalary_Click:
    Exit Sub

Err_cmdSalary_Click:
    MsgBox Err.Description
    Resume Exit_cmdSalary_Click
End Sub
 
And what about the Recalc method of the form ?

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
PHV,
Thank you for the tip. I never knew about the Reclac method. After you suggested it, I looked it up in help and it siad:

The Recalc method immediately updates all calculated controls on a form.

It works like a charm. Thanks for pointing me in the right direction.
Dom

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top