473,804 Members | 3,607 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.ne t

Nov 12 '05 #1
2 2636
"Jade Tippett" <ja**@pacific.n et> 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.ne t

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(Cance l As Integer)

If Me.OpenArgs = "MyKeyWord" Then
Me.cmdSpecial.V isible = True
Me.txtSpecial.V isible = True
DoCmd.GoToRecor d , , 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.n et> wrote in news:403157B1.3 040104
@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.ne t


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!cmd New_Record_Clic k

Bob Q

Nov 12 '05 #3

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

Similar topics

1
3553
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 modular and work across forms and sub-forms. My previous code was taken from the Access Expert Solutions 97 (Leszynski) many years ago. As my database became more complex with multiple sub-forms and intricate combo boxes, the code faltered. Some...
0
5756
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 selected, it causes the ServerClick event to be called twice. Here's the code: You'll see that there are two grids on the page, and that the function SetupDataGrid populates data to the two grid. There are also
5
3376
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 message is displayed... How can this be done? Can I make the section visible via server-side code? Via Response.Write()? Any examples would be appreciated!
7
4265
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" value="Merchant Name"> <input type="hidden" name="OrderID" value="Unique OrderID value"> <input type="hidden" name="email" value="Customers email address (OPTIONAL)">
7
2580
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 upgraded to VB.NET, and I have a lot of catching up to do. That being said, I have come a long way in a short while, however, I am stumped at the moment. I have read through days of posts, but have not been able to address my specific question, so...
15
62101
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
1573
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 context, the panel of a form which contains various buttons , are shown or hides. Now at design time i set the default button property to one of button. But when the form object is created in different context and set visibilty of default
5
2543
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 background thread off the pool. I stepped through the logic, and everything seems to go through fine when the control is initialized, and my main form continues to work correctly. The only issue is that the control seems to not render properly...
0
1133
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 is transformed to a query and the oraclecommand open is and the oraclereader execute it. That works fine. But when the oraclereader tries to read the first record, it takes a long time. This is normal, a like predicates instructs the...
0
9579
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10326
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10317
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10075
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9143
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5520
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5651
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4295
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2990
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.