473,230 Members | 1,770 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,230 software developers and data experts.

Running Button Method from Another Form

I am trying to design a button in one form that opens
another form and executed a button method within that form.

I want to button to open a form based on a different table,
then execute the code connected with a cmdNew_Record button
in the second form. This command shows several hidden
buttons and instructions, as well as opening a blank record.

I have tried a line "RunCommand acRunCmd..." to try to get
the second method to run, but I keep getting argument errors.

I tried changing the "Private Sub" to "Public Sub" on the
header for the method I want to run, but that did not do
any good.

Thanks for your assistance in advance.

ps: In case it's not obvious, I'm a neophyte, a high school
teacher trying to keep my mind alive.

--jade
ja**@pacific.net

Nov 12 '05 #1
2 2600
"Jade Tippett" <ja**@pacific.net> wrote in message
news:40**************@pacific.net...
I am trying to design a button in one form that opens
another form and executed a button method within that form.

I want to button to open a form based on a different table,
then execute the code connected with a cmdNew_Record button
in the second form. This command shows several hidden
buttons and instructions, as well as opening a blank record.

I have tried a line "RunCommand acRunCmd..." to try to get
the second method to run, but I keep getting argument errors.

I tried changing the "Private Sub" to "Public Sub" on the
header for the method I want to run, but that did not do
any good.

Thanks for your assistance in advance.

ps: In case it's not obvious, I'm a neophyte, a high school
teacher trying to keep my mind alive.

--jade
ja**@pacific.net

I can think of a number of ways to approach this, but one possible avenue to
explore is to look at the OpenArgs parameter you can pass when you use the
DoCmd.OpenForm. For example,

DoCmd.OpenForm "frmTwo", , , , , , "MyKeyWord"

will open a form named "frmTwo" passing a string "MyKeyWord"

This can be picked up in frmTwo's Open event
Private Sub Form_Open(Cancel As Integer)

If Me.OpenArgs = "MyKeyWord" Then
Me.cmdSpecial.Visible = True
Me.txtSpecial.Visible = True
DoCmd.GoToRecord , , acNewRec
End If

End Sub
In other words, if you open frmTwo normally, nothing happens. But if you
pass it "MyKeyWord" as a OpenArgs parameter, it knows it needs to open in a
'special way' and run that code.

Does that make sense?
Fletcher
Nov 12 '05 #2
Jade Tippett <ja**@pacific.net> wrote in news:403157B1.3040104
@pacific.net:
I am trying to design a button in one form that opens
another form and executed a button method within that form.

I want to button to open a form based on a different table,
then execute the code connected with a cmdNew_Record button
in the second form. This command shows several hidden
buttons and instructions, as well as opening a blank record.

I have tried a line "RunCommand acRunCmd..." to try to get
the second method to run, but I keep getting argument errors.

I tried changing the "Private Sub" to "Public Sub" on the
header for the method I want to run, but that did not do
any good.

Thanks for your assistance in advance.

ps: In case it's not obvious, I'm a neophyte, a high school
teacher trying to keep my mind alive.

--jade
ja**@pacific.net


To open the second form, use the docmd.openform "form2"

Then, you need to trigger the On Click event procedure belonging
to the cmdNew_Record button on this form that does the actions
you have programmed.

In order to do this, the sub procedure must be public.
All you need is to add the following line in your first form's
button, after you open the form. You might need to insert a delay
to allow the form to open, so

dim x as single
x = timer
do while timer < x + 1 ' gives 1 second delay.
DoEvents
Loop
CALL forms!form2!cmdNew_Record_Click

Bob Q

Nov 12 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Robert Neville | last post by:
I am having some trouble with some old code revolving around custom form navigation buttons. My main form has a sub-form with these custom navigation buttons. In other words, the code should be...
0
by: Oz | last post by:
Hi Using VS.NET 2003, Windows XP SP1, We have a page which has been developed using ASP.NET. On it, is a button which when clicked is supposed to add some data to a table. When the button is...
5
by: PontiMax | last post by:
Hi, when I press the OK button of my dialog box a long-running task is initiated. Therefore I would like to make visible a div section right after clicking the button where a user-friendly...
7
by: | last post by:
Hello, I would like to do the following from a asp.net button click: <form method="POST" action="https://www.1234.com/trans_center/gateway/direct.cgi"> <input type="hidden" name="Merchant"...
7
by: MgGuigg | last post by:
Hello all, This is my first time posting a question to this forum, so here is hoping I am following protocol. I am scraping the rust off my old Basic programming skills, and have just recently...
15
by: Oleg Subachev | last post by:
I need to programmatically invoke from other class Click event of the Button on my Form. Button.OnClick method is protected, not public. How to perform this ? Oleg Subachev
3
by: Anil Kumar Sharma | last post by:
Hello, I am working on C# using vs.net 2003. I have faced two interesting problems. 1. Dynamically setting Default Button: I created a form and used it in various contexts. On basis of the...
5
by: RWF | last post by:
I have a form, and from the form when a user clicks a button, it instantiates control that will be doing a lot of logic. I am trying to use System.Threading.ThreadPool.QueueUserWorkItem to spawn a...
0
by: peter palus | last post by:
Hi, I have a problem, how to cancel a running oracle-query. The situation: The user can type in a form, which kind of information he wants to now e.g. articletext like 'abc%'. This information...
0
by: VivesProcSPL | last post by:
Obviously, one of the original purposes of SQL is to make data query processing easy. The language uses many English-like terms and syntax in an effort to make it easy to learn, particularly for...
0
by: jianzs | last post by:
Introduction Cloud-native applications are conventionally identified as those designed and nurtured on cloud infrastructure. Such applications, rooted in cloud technologies, skillfully benefit from...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...

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.