Button to Link one form to another

manny_cb

Registered User.
Local time
Yesterday, 20:43
Joined
Jul 31, 2008
Messages
16
Hey All,

I have two forms.. the second one is basically a continuation of the first form..
form 1 and 2 have the same contact information at the top since they are both linked to the same table.
Now I wana have a continue button at the bottom of page 1 which will save and close form1 and openup form2 with the contact info already there... similarly i would like a back to page1 button at the bottom of form2 which would do the same... your help is greatly appreciated.. thanks!
 
If I may ask .. would a tab control be better suited?

-dK
 
well sure.. i wasnt too sure how to go about this.. basically i have a long list of interview questions.. but they dont all fit in one form.. so i figured i could just make two forms and link them.. how woould the tab control work ?? thanks in advance..
 
This is the exact situation that tabbed pages were designed for! Here's a quick little tutorial a lot of people have found useful:

First thing to remember is that the Tabbed Pages are all part of a single form; think of it as a really long form turned on its side. Because it is all one form, all referencing to any control on it is done in the same manner as if they were all on one single screen. Create a form in Design View. Goto the toolbox and click on the Tabbed Control icon; it actually looks like several manila file folders. Place it on your form and adjust the size to your liking. If you need more than the two tabbed pages it initially gives you, click on the tabbed control to select it. Goto Insert and click on Tabbed Control Page and another tabbed page will be added. Do this as many times as necessary.

This is the really important part: when you go to add a control to a tabbed page, you must first click to select one of the pages, then add the control. Otherwise, the control will be added to the form itself, and will show thru on all tabbed pages!

Once you have the form's Control Source (your table or a query) set up, you simple add controls as you normally would, heeding the above paragraph.

Also important to understand! If you go to move a control from one part of your main form to a tabbed page, cannot drag and drop it! You must cut it, select the tabbed page, then paste it! And if the control has any code behind it, a GotFocus, OnClick, etc, after dropping it on the tabbed page, you'll have to "re-connect" it to its code. Select the control, goto Properties, click to the right of [Event Procedure] on whatever event to bring up the ellipsis (...) then click it to go to the code window. Exit the code editor and the control and its event code will be connected.[/font] One last thing. When trying to access the Properties of the Tabbed Control, such as the BackStyle, people complain that they can't find property. The problem is that they haven't selected the Tabbed Control, they've selected one of the pages of the Tabbed Control! The best way to be sure of selecting the Tabbed Control itself is to click to the right of the last tab. If you have 2 tabs, for instance, click in the blank area where Tab 3 would be, if you had a
Tab 3.
 
Quick Crash Course in Tab Control

No problem.

I understand that you don't want a long scrolling form, to overcome this I use the tab control. I size the tab control accordingly so the user does not need to scroll for it either.

In form design view, click on the tab control tool and draw one on your form (like you do text boxes). If you already have text boxes and such on your form, you can 'cut' those and paste them on the page (each tab is called a page) you want them on. Select your controls, cut, and then click on the page you want them on. There is a difference between selecting the tab control and the current page - when selected they almost look identical. And then paste. If you are just now creating the text boxes, make sure you have the page you want them on selected.

If you do not have the page selected, it will probably paste to the form and be visible through the tab (that is just how it works). You can take advantage of this fact by using lines on the form to make sure controls on each page line up exactly, etc.

Note: Each tab order for controls of each page has to be set per each page.

To insert/remove/reorder pages can be accomplished by right-clicking the tab control. To rename the pages, you will need to get on the properties form of the page itself.

Note: You have control over the page-tab width, height, font, etc, through the Format of the tab control (in properties).

As a strategy, I try to group like items on each page and name the page the grouping them. For instance, Page1 might be 'Personal Information', Page 2 might be 'Contact Information', so on and so forth.

Hope this helps.

-dK
 
thanks a lot for your help guys.. i have two concerns now.. firstly can you change the color of the tab.. i was able to change the color of the page to transparent but cant figure out how to change the tabs.. also i need to be able to print the record... how can i make it so it will print all the pages in the control.. but that record only... thansk again for all the help :)
 
Yeah .. that ole change the color of the tab thing. =] It can be done with smoke and mirrors - at least I've read about it (using graphic controls) but never did it myself. Might be able to do some Google searches using 'ms access custom tab color' to pull up a few hits.

Okay .. for the report ...

1. Create the report (you can use the wizard to get everything built and then address the cosmetics through design or start from scratch with a blank report)

2. Create a command button on your form (or wherever)
3. In the properties of the command button, initiate the Code Builder for the OnClick() event.
4. Input the following code in the VB editor and change items where appropriate (report naming, ID names).

Code:
Private Sub cmbCommandButtonName_Click()
[INDENT]Dim sReportName As String
Dim sFilter As String
[/INDENT][INDENT]sReportName = "rptReportName"
sFilter = "[tblTableID]=" & Me![ThisRecordID]
[/INDENT][INDENT]DoCmd.OpenReport sReportName, acViewPreview, sFilter
[/INDENT]End Sub


-dK
 

Users who are viewing this thread

Back
Top Bottom