Welcome to the dBforums forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions, articles and access our other FREE features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload your own photos and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact contact support.

If you prefer not to see double-underlined words and corresponding ads, place your cursor
here for ContentLink opt out.

Go Back  dBforums > PC based Database Applications > Microsoft Access > Form navigation help

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 12-29-03, 13:32
JD| JD| is offline
Registered User
 
Join Date: Dec 2003
Posts: 37
Form navigation help

Hi I have search everywhere for help on this subject and these forums seem to have good advice!

I have to create a project for my night class at college using access.
As a non-windows user I haven't used this program before, but have got to grips with the basics now the problem...

I want to create a single form with several buttons to the left and when each button is clicked it opens the form as a subform.

Problem I have is I can only get these forms to open in new windows. I have looked at the code but having never used it am at a loss as to what to change

Any help gratefully received

JD
Reply With Quote
  #2 (permalink)  
Old 12-29-03, 19:06
Norberto Norberto is offline
Registered User
 
Join Date: Aug 2003
Location: Argentina
Posts: 465
Try to clarify the idea that you want.
__________________
Saludos
Norberto
Reply With Quote
  #3 (permalink)  
Old 12-30-03, 03:04
CyberLynx CyberLynx is offline
Stuck on my opinions...
 
Join Date: Nov 2003
Posts: 1,487
Create all your subforms onto the form which contains the buttons. Make sure each subform control has the Visible property set to False. Now, use each button on your form to set the Visible property for each corresponding subform to True and all others to False (You can create a procedure to do this). You can also set the subform size/positioning properties (Left, Top, Height, & Width) from your buttons or procedure as well. Just off the top of my head...

Example:
In the OnClick event of your buttons:

Code:
Private Sub Command1_Click () 'View a specific SubForm Control Call OpenMySubForm(Me.mySubFormName1) End Sub Private Sub Command2_Click () 'View a specific SubForm Control Call OpenMySubForm(Me.mySubFormName2) End Sub 'etc.....
Copy and paste this procedure into the same form code module that contains the buttons and subforms:

Code:
Private Sub OpenMySubForm (Sfrm as Control) 'Close ALL SubForm Controls. Dim Ctrl as Control For Each Ctrl In Me.Controls If Ctrl.ControlType = acSubform Then Ctrl.Visible = False Next Ctrl 'Position The SubForm Control. Sfrm.Left = WhereverYouWantIt '(in twips - 1" = 1440 twips) Sfrm.Top = WhereverYouWantIt '(in twips - 1" = 1440 twips) Sfrm.Height = WhereverYouWantIt '(in twips - 1" = 1440 twips) Sfrm.Width = WhereverYouWantIt '(in twips - 1" = 1440 twips) 'Make the SubForm Visible. Sfrm.Visible = True End Sub


There ya go....
Reply With Quote
  #4 (permalink)  
Old 12-30-03, 09:05
JD| JD| is offline
Registered User
 
Join Date: Dec 2003
Posts: 37
Thanks That will do exactly what I want !

I have tried this and think the buttons work but the subforms still stay invisible.

Is it possible to add each set visible and set invisible in each event
so command 1 would have set client visible, set employee invisible,set project invisible. ?

client is the name of my first subform !

Thanks again

JD
Reply With Quote
  #5 (permalink)  
Old 12-31-03, 01:46
CyberLynx CyberLynx is offline
Stuck on my opinions...
 
Join Date: Nov 2003
Posts: 1,487
I'm not sure exactly what you mean. Never the less...I have now tested the code posted and all works fine. If you find that the subforms are not coming into view (visible) that it may be possible that your positioning statements (.Left, .Top, etc.) are placing the subforms into the dark zone (so to speak) of your form. Try rem'ing out the Positioning statements.

Quote:
Is it possible to add each set visible and set invisible in each event
so command 1 would have set client visible, set employee invisible,set project invisible. ?
Now, if you mean (by your question) whether or not you can control the visible property of each subform within the OnClick event of each command button....the answer is "Yes". But this requires a lot of unnecessary code (see the example below). Each button would need to make visible its' respecitive subform and make invisible all other subforms. This could look rather cryptic should you have lets say, 15 or 20 subforms. The choice is really up to you but better coding practice would be to keep the code as short as possible thus creating a faster, smaller, maintainable, and easier to read application.

Code:
Private Sub Command1_Click() 'Hide unwanted SubForms. Me.Employee.Visible = False Me.Project.Visible = False 'Set SubForm position. Me.Client.Left = 1.25 * 1440 Me.Client.Top = 1.5 * 1440 Me.Client.Height = 2 * 1440 Me.Client.Width = 3.5 * 1440 'Set the "Client" SubForm visible. Me.Client.Visible = True End Sub Private Sub Command2_Click() 'Hide unwanted SubForms. Me.Client.Visible = False Me.Project.Visible = False 'Set SubForm position. Me.Employee.Left = 1.25 * 1440 Me.Employee.Top = 1.5 * 1440 Me.Employee.Height = 2 * 1440 Me.Employee.Width = 3.5 * 1440 'Set the "Employee" SubForm visible. Me.Employee.Visible = True End Sub Private Sub Command3_Click() 'Hide unwanted SubForms. Me.Client.Visible = False Me.Employee.Visible = False 'Set SubForm position. Me.Project.Left = 1.25 * 1440 Me.Project.Top = 1.5 * 1440 Me.Project.Height = 2 * 1440 Me.Project.Width = 3.5 * 1440 'Set the "Project" SubForm visible. Me.Project.Visible = True End Sub
See what I mean....
Reply With Quote
  #6 (permalink)  
Old 12-31-03, 10:05
JD| JD| is offline
Registered User
 
Join Date: Dec 2003
Posts: 37
Thank You so much With your help I'm slowly begining to get to grips with this have now got all subforms showing when they are ment to.

One other thing I can't seem to get working atm on one of the forms I use a Insert statement, but I can't get it to insert into the row of the form I am editing.

i.e it inserts into the next row. I know it needs a Insert into where in php I would use this INSERT INTO CLIENT WHERE id =$id clientclass values(1);

but not sure how to reference variables in vb here is what I have...
Code:
sql = ("INSERT INTO [CLIENT](ClientClassID)VALUES (1);") DoCmd****nSQL sql

JD
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On