Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access VBA
|
Access VBA Discuss using VBA for Access programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old June 10th, 2003, 02:31 PM
Registered User
 
Join Date: Jun 2003
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default How to start a form's click procedure by opening t

I want to start a click procedure tied to a form upon opening the form. I want to do that in code for a click procedure in another form. Is that possible? I have the following:

Sub Start_Click()
(stuff goes here)
    DoCmd.Close acForm, "frmBlank1_EPD", acSaveYes
    DoCmd.OpenForm ("frmBlank2_TermAndValue")
end sub

That works fine to open the second form, frmBlank2_TermAndValue. However, I can't figure out how to get
frmBlank2_TermAndValue to run its Go_Click procedure (for command button named
"go") upon opening the form. When I set the on open property to run the Go_Click procedure as shown below, I get an error generated by frmBlank2_TermAndValue's error handler.

Private Sub Form_Open(Cancel As Integer)
Go_Click

Rick Neifeld, Ph.D. Patent Attorney
President, Neifeld IP Law, PC
2001 Jefferson Davis Highway, Suite 1001
Arlington, VA 22202
Tel: 703-415-0012
Fax: 703-415-0013
Email: rneifeld@neifeld.com
www.Neifeld.com
 
Old June 11th, 2003, 10:48 AM
Authorized User
 
Join Date: Jun 2003
Posts: 22
Thanks: 0
Thanked 0 Times in 0 Posts
Default

You could set a new Sub that is called by both the Form_Open and the Go_Click events:

Private Sub newSub()
  DoCmd.Close acForm, "frmBlank1_EPD", acSaveYes
  DoCmd.OpenForm ("frmBlank2_TermAndValue")
end sub

Private Sub Form_Open(Cancel As Integer)
 newSub
End Sub

Private Sub Go_Click(Cancel As Integer)
 newSub
End Sub


Hope that helps


-Shay Shepston





Similar Threads
Thread Thread Starter Forum Replies Last Post
Opening MDI Child on Button Click of MDI Child Sachin Shinde Visual Studio 2005 0 June 8th, 2006 05:05 AM
Opening recordset based on stored procedure misterqj Access 2 March 17th, 2005 10:09 PM
Form's nightmare C# 3 December 19th, 2004 12:40 AM
ComboBox Click even firing when opening workbook bennyD Excel VBA 0 March 2nd, 2004 05:02 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.