473,378 Members | 1,383 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,378 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 2605
"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: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.