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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Executing 2 Commands or Events by One Button

Status
Not open for further replies.

sanan

Technical User
Apr 15, 2004
139
IR
Hi Every Body
Is it possible to Execute 2 Events by one Button?
Let me Explain a Little, I have a Form and a in it a Subform, My sub Form is in DataSheet View, and There is a Master and Child Link Field between the 2 Forms.
On My sub form there are 2 Text Boxes,

I removed my Navigation Buttons from my Form and I Put my Own Navigation Buttons,
There is also a Button on My Form that refreshes my Subform.

Here is the Challenge I want to be able by pushing for Example my Add New Button on My form, First of all the Refresh Button to be Pushed and Then Run the Following Sub:

Private Sub Command108_Click()
If Me!Sd <> Me!SC Then
MsgBox "Entries are out of Balance", vbOKOnly, "Inventory101"
Else
DoCmd.GoToRecord , , acNewRec
End If
End Sub

Where SD and SC are two Text Boxes on My Original form Equal to Exact same Name Text Boxes on my Sub Form, which they are the Sum Of My 2 Text Boxes on the Sub Form.

Is it Possible?
If You want to Put My Refreshing Button Code in My add new Button Code is fine

Best Regards
sanan



 
Have you tried this as first instruction in Command108_Click ?
Call NameOfPushButton_Click()

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Hi PHV
Thank you for quick reply.
Yes, I tried it but it did not work.
This is my refreshing Button;
Private Sub Command153_Click()
Me.Account_Details.Requery (Account details is my sub Form)
End Sub

This is My add New Record Button On_click code:
Private Sub Command108_Click()
If Me!Sd <> Me!SC Then
MsgBox "Entries are out of Balance", vbOKOnly, "Inventory101"
Else
DoCmd.GoToRecord , , acNewRec
End If
End Sub

And I tried Adding My command 153 Button or it’s code into my command108, But it just does not work, following code Does not work:
Private Sub Command108_Click()
Command153_Click Or Using it’s code: Me.Account_Details.Requery
If Me!Sd <> Me!SC Then
MsgBox "Entries are out of Balance", vbOKOnly, "Inventory101"
Else
DoCmd.GoToRecord , , acNewRec
End If
End Sub

Above does not work, That is even if I enter non equal values in my text Boxes, I do not see my MsgBox, But if I push the Command153 Button then I push my Command108 Button, I do get my MsgBox in case of non equal entries.

Best regards
sanan


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top