473,403 Members | 2,293 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,403 software developers and data experts.

invoke a form with a button from another

is there a way to make a button on a form open another form with the same record and carry over some of the data from the initial form?
Dec 15 '08 #1
8 1821
beacon
579 512MB
@trixxnixon
Hi Trixx,

Let's take this one step at a time. To open a form with a command button add the following VBA code:
Expand|Select|Wrap|Line Numbers
  1. Private Sub cmdOpenForm_Click()
  2.  
  3.    'Use the DoCmd to open the form, acNormal is the view the form is opened in
  4.    DoCmd.OpenForm "NextForm", acNormal
  5.  
  6. End Sub
  7.  
If you need to pass parameters, we need to figure out how much data you are trying to pass because there are different methods of doing so.

For instance, if you need to pass the value of one text box, you VBA would look like this:
Expand|Select|Wrap|Line Numbers
  1. Private Sub cmdOpenForm_Click()
  2.  
  3.    'Declare a variable to hold the value of the text box
  4.    Dim myVar
  5.  
  6.    'Set the value of the variable equal to the text box
  7.    myVar = txtAddress.Value
  8.  
  9.    'Now use the OpenForm method and use the variable in the_
  10.        OpenArgs section, which is the 5th comma after acNormal
  11.    DoCmd.OpenForm "NextForm", acNormal, , , , , myVar
  12.  
  13. End Sub
  14.  
Then on the form you are trying to open, I would create an invisible text box called myParameter and then enter the following VBA code:
Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_Load()
  2.  
  3.    'Set the myParameter text box equal to OpenArgs
  4.    myParameter.Value = me.OpenArgs
  5.  
  6.    'Then you can set the desired text box equal to myParameter
  7.    txtSecondAddress.value = myParameter.Value
  8. End Sub
  9.  
If you need to pass multiple pieces of data, then you have to put each parameter in OpenArgs, separate each with an ampersand (&) and a semicolon in quotations. Then, once you've passed the OpenArgs, you have to separate each piece of data with the Split() function.

I'm not going to rewrite it because missingLinq has already done it. Here's a link to the page that helped me out tremendously and changed the way I look at forms. http://bytes.com/topic/access/answer...ue-form1-form2

Hope this helps

- beacon
Dec 15 '08 #2
@beacon


i only need to transfer the data from one text box from another, this should help. i am going to try it right now.

thank you for such a quick responce.
Dec 15 '08 #3
beacon
579 512MB
Let me know how it works out.

If you get this down, you can move on to the step I just recently got to work...reading a parameter from user input on an initial form and then passing it to each subsequent form (including the Switchboard) to ensure that the user only selects data that pertains to them.

This just involves putting a myParameter invisible text box on each page that should receive the parameter and making sure that the parameter is passed in OpenArgs.

So, let's say I open the db and the form asks me to select myself from the list. I choose my name, select submit, and I'm taken to the Switchboard and a text box says "Welcome back beacon!" Then I choose to open another form, and in the name field it already has beacon. Using it with DLookup, I could potentially fill in other information that relates to me as long as the parameter is passed successfully.

Anyway, just some things to try if you get your initial question to work properly.

- beacon
Dec 15 '08 #4
@beacon


oh no, i got it to work with no problem, i still dont quite understand the open argument, but i know how to use the basic principle.

so now that i have the correct field populating with the parent forms data,
i want a subform to take this tracking number, and plug it into a query and display all the records relating to that specific number.

i guess what i am asking is, would this be possible? and would it be the best design for this type of need?
Dec 15 '08 #5
beacon
579 512MB
@trixxnixon
Open Argument is something that attaches to the command as it performs its action. Not sure that's the best technical explanation for it, but it works for me. Here's a corny analogy to help explain OpenArgs:

When you run the command, think of it as a pizza being delivered. OpenArgs are the side items that come with the pizza...napkins, parmesan cheese, red pepper, etc. But the pizza delivery place you ordered from doesn't just give you the side items all the time, you have to specify what you want. As long as you specify it, the items will come with your pizza guaranteed (take that Pizza Hut!).

When the command has run, in your case when it has opened the second form, that's like you accepting the pizza at your front door, as well as the side items. Once you've got the side items, it's up to you how you put them to use. Maybe you put parmesan on pepperoni pizza or red pepper on anchovi (haha) pizza...it's all up to you. This is when you set your text box equal to the me.openargs.

so now that i have the correct field populating with the parent forms data,
i want a subform to take this tracking number, and plug it into a query and display all the records relating to that specific number.

i guess what i am asking is, would this be possible? and would it be the best design for this type of need?
I'm not sure I understand the second part of your question because I don't have a ton of experience with subforms. Is the tracking number the parameter that you passed through OpenArgs?

When you open the second form, does the query you're talking about automatically run with all data and now you want to limit the search to just those that match the tracking number?
Dec 15 '08 #6
FishVal
2,653 Expert 2GB
Here you may find some additional indormation on this topic.

Regards,
Fish
Dec 15 '08 #7
@beacon

right after i posted this i was able to get it working,

thanks for your help by the way, i hope one day i can return the favor.
Dec 16 '08 #8
@FishVal
you really know your stuff. how long have you been doing this?
Dec 16 '08 #9

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: RickDee | last post by:
Please help, anybody. I am trying to write a program so that it can launch an exe file ( which is also genereated in C# ) and then simulate the button clicking and invoke the methods inside the...
4
by: SteveS | last post by:
Does anyone know if it is possible to invoke a Javascript function in a web page from an external application? I've got some data that I want to pass from a windows application to a web page...
4
by: Altramagnus | last post by:
I have a form first created my the main thread. I have another thread monitoring the IO. Upon receiving certain message, I want to show/unhide the form. When the form is first created ( handle...
7
by: Jeff Stewart | last post by:
I need a thread to run a subroutine which updates my main form's progress bar. I've properly marshaled all UI updates to the main UI thread, and after the main thread starts the worker thread, it...
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
11
by: cindy | last post by:
I have a form, has javascript registered so a modal pops up. Button click will close form. Now I need to do an update with modal form data before it closes. I can put a second button and register...
4
by: Chris Dunaway | last post by:
I have a main form with a "lock" button. When the lock button is clicked, another form is shown using ShowDialog(this). The user must enter their PIN on this form to close it and resume the main...
6
by: k.mellor | last post by:
Hi, I hope someone can help. I have written a simple form to demonstrate my problem/question. The code follows. The form starts a thread, which using delegates updates a label (Every second...
8
by: =?Utf-8?B?UmljaA==?= | last post by:
My from contains a "Move Next" button. When the user clicks on the "Move Next" button - several procedures get invoked and eventually, the dataset underlying the form will display main data from...
6
by: Dom | last post by:
I'm teaching myself about delegates and the Invoke method, and I have a few newbie questions for the gurus out there: Here are some CSharp statements: 1. public delegate void MyDelegate (int k,...
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: 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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...
0
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...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
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...
0
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...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.