Subforms

G

Griffij

I was wondering if anyone could answer this question for
me.

If I click on a suborm ftom a a main form how do I get
that form to open to open on it's own thus hiding the
main form.

The reason I ask is tht I have the subforms that come off
the main form and if they were to share the same space it
would be very crowded.

Instead of using tab tops at the op of the form is there
any way I can use buttons as I brefer them

Many thanks

Griffij
 
J

John Vinson

I was wondering if anyone could answer this question for
me.

If I click on a suborm ftom a a main form how do I get
that form to open to open on it's own thus hiding the
main form.

You can't, not as a Subform. It will need to be a separate,
freestanding Form, opened with a DoCmd.OpenForm command. To do so
*and* maintain the synchronization of data that you get with Subforms,
you'll need some VBA code; you will need to (for instance) pass what
would be the Master Link Field value in the OpenForm's OpenArgs
parameter, and write code in the "sub"form's Open event to set the
default property of the Child Link Field to the passed value. Doable,
but requires a bit of code!
The reason I ask is tht I have the subforms that come off
the main form and if they were to share the same space it
would be very crowded.

Instead of using tab tops at the op of the form is there
any way I can use buttons as I brefer them

There are several ways of changing the appearance of Tab controls - I
think one of them uses buttons, but I haven't experimented with it.
 
G

Griffij

If I was to put a butto on the form what would the code be

I want the subform to openas as form in there own right
but how do I do that?
 
A

AJ Raiber

The base code would be

private sub cmdButton_Click()

dim varID as variant

varID = fldMyIDField

DoCmd.OpenForm "MyForm", , , IDFld = varID, acFormAdd,
acWindowNormal

End Sub

This will add this as a new record in the form. If it
needs to edit a record in the form, then you would need to
change the "acFormAdd" to "acFormEdit". Without the
working DB I cannot be more specific than this. of course
the field names and form name will need to be changed.
Hope this helps.

AJ
 
G

Guest

Dear John

Can you give me an example of how I would go about
linking all forms pass the Parent / Child link


I lust want it to work right

Thanks

Griffij
 
G

Guest

I have four forms in my database which all of the same
Primary Key (EmpNatins)

What I am want is link tem all together The first form
Stores all the Personal information.

Now what I am tryibng to achievve is that when a user
clicks on a form button it the opens that for with the
EmpNatIns already inputed.

Griffij
 
A

AJ Raiber

Is this form strictly based on the user? Do they have
access to only one EmpNatins or is this one person using
multiple records (EmpNatins)?
 
J

John Vinson

Dear John

Can you give me an example of how I would go about
linking all forms pass the Parent / Child link


I lust want it to work right

Since I don't know what is "right" in your terms, nor do I know how
the tables underlying the forms are related, any advice I give will be
a rough approximation, but...

Try the following: in the Click event put code like

DoCmd.OpenForm "MyForm", _
WhereCondition := "[EmpNatins] = " & Me!EmpNatins, _
OpenArgs := Me!EmpNatins

And in MyForm's Open event, put code like

Private Sub Form_Open(Cancel as Integer)
If Me.OpenArgs & "" <> "" Then
Me!EmpNatins.Default = Chr(34) & Me.OpenArgs & Chr(34)
End If
DoCmd.GoToRecord acNewRecord ' if you want to open ready for new input
End Sub
 
G

Griffij

Heere is a brief example of what the database is supposed
to do.

It is supposed to hold data relating to employees that
work for a business.

It is suppoed to hold dat relating to there Personal
information (Every Employee as a National Insurance
Number)this is the one number that is Unique to each
Person)

It also hold data on Emergency contact Information should
they ever the business ever need it.

It also will hold data on there employment as well as
driving information. (A list of all these tables follows
below)

Now my vision should you call it that is; Each tables has
a corrisponding form. The way I see it is all the tables
will be linked back to the Employee Personal Information
by A 1:1 relationship so in each table it as EmpNatIns as
the primary key.

What I am wanting to do is Open the first form enter in
there personal data and the click on any of the other 3
buttons on the form and fill in that informtion relating
to that form. but hat it relate eo the person I entered
Personal information for.

I wish to keep the forms clean and tidy with only the
relevant information on each form.

I want to only enter the EMPNATINS once in the fist form
and no mater what form button I click on for it o be
carried forward.

Well I do hope that this information will prove to be of
help in trying to achieve my vision. I would be extremly
greatful if you could provide ideas.

Many thanks Griffij

Ps Plese find below a list of the tables:

Employee_Personal_Information (Table 1, Main Table)

PKEmployNatINS
Employdob
Employsurname
Employfirstname
Employtitle
Employhousename
Employaddress
Employtown
Employcity
Employcounty
Employpostcode
Empoloytelnumber
Employmobile
Employsecondtelnumber
Employfaxnumber
Employemail
Employnotes

Employee_Emergency_Information (Table 2, Subform)

PKEmployNatINS
EmployRelationship
EmployRelsurname
EmployRelfirstname
EmployReltitle
EmployRelhousename
EmployReladdress
EmployReltown
EmployRelcity
EmployRelcounty
EmployRelpostcode
EmpoloyReltelnumber
EmployRelmobile
EmployRelCompany
EmployRelCompanynumber
EmployRelextention
EmployRelNotes

Employee_Employment_Information (Table 3, Subform)

PKEmployNatINS
EmployEmpJobtitle
EmployEmpStartdate
EmployEmpEnddate
EmployEmpNotes

Employee_Driving_Information (Table 4, Subform)

PKEmployNatINS
EmployDriveYesNo
EmployDriveLicNo
EmployDrivePassDate
EmployDrivePointsYesNo
EmployDriveNotes
 
J

John Vinson

It is suppoed to hold dat relating to there Personal
information (Every Employee as a National Insurance
Number)this is the one number that is Unique to each
Person)

It also hold data on Emergency contact Information should
they ever the business ever need it.

It also will hold data on there employment as well as
driving information. (A list of all these tables follows
below)

Are you QUITE certain that these should be one-to-one relationships?
What do you do for employment information if someone has two jobs
(concurrently or sequentially)? Is there only *one* driving
information record? Will someone be allowed one and only one emergency
contact?
 
T

tina

john vinson's code examples showed you how to achieve
exactly what you describe below. if that's beyond your
current skill level in VBA, you'd probably make your life
a lot easier by just putting linked subforms on a tabbed
(using the button option) form. by linking the subforms to
the main form in the Properties box in design view, you
won't have to write any code at all.
 
G

griffij

Dear John

As far as I can see yes everyone only has one piece of
information and should it chsnge, the old data would be
over written

I am not sure how you mean it. putting it in linked
subforms with tabs please gin an example

Griffij
 
G

Guest

Dear John

Hi I have tried the code that you suggested and it goes
in ok but when I try to run it, it say that the form "
Employee_Emergency_Informaton Subform" Does not exist or
is mispelt.

Can you help

EmpNatINS is a mixture of both numbers and letters, does
that make a difference?

The code entered is below

DoCmd.OpenForm "Employee_Emergency_Informaton Subform", _
WhereCondition:="[EmpNatins] = " & Me!EmpNatIns, _
OpenArgs:=Me!EmpNatIns
 
J

John Vinson

Dear John

Hi I have tried the code that you suggested and it goes
in ok but when I try to run it, it say that the form "
Employee_Emergency_Informaton Subform" Does not exist or
is mispelt.

Since the form name contains a blank, you probably need to enclose it
in square brackets... and is it "Informaton" or "Information"?
Doublecheck the Name property of the Form.
Can you help

EmpNatINS is a mixture of both numbers and letters, does
that make a difference?

and yes, if it's a Text field you need quotemarks. Try:

DoCmd.OpenForm "[Employee_Emergency_Informaton Subform]", _
WhereCondition:="[EmpNatins] = '" & Me!EmpNatIns & "'", _
OpenArgs:=Me!EmpNatIns
 
J

John Vinson

Dear John

As far as I can see yes everyone only has one piece of
information and should it chsnge, the old data would be
over written

Well... ok. Seems like VERY peculiar design to me, but it's your data!
I am not sure how you mean it. putting it in linked
subforms with tabs please gin an example

Create a Tab Control on the form.

Set its Properties so that it displays buttons instead of tabs (since
that look is apparently important to you).

Insert as many pages as you have subforms.

Select each page in turn and copy and paste the subform from the Forms
window onto it.

Set the Master/Child link fields appropriately on each Subform.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top