Opening to specific record

G

Guest

Hi,

I have a staff details form which has a link to a training record form. I
would like this link to go to the same staff member as the one shown on the
details form. How would I go about this?

We also have links to queries and reports on the same page which I have
managed to synchronise with the details form but synchronising another form
appears to be more difficult.

My VB skills are virtually non existent.

Please help

Ian
 
K

Keith Wilby

NoviceIan said:
Hi,

I have a staff details form which has a link to a training record form. I
would like this link to go to the same staff member as the one shown on
the
details form. How would I go about this?

I think we need more info but I'll assume that you have a 'staff' table and
a 'training' table with a one-to-many relationship between them and that
your 'staff details' form is the main form and 'training record' is its
subform. If this is the case then you need a parent/child data link on your
primary and foriegn keys.
We also have links to queries and reports on the same page which I have
managed to synchronise with the details form but synchronising another
form
appears to be more difficult.

I'm confused by the use of the word 'synchronise' here. Forms can have data
sources which can be tables and/or queries. As I say I thnk more info is
required but is sounds as if you may have a fundamental relationship problem
at table level. Perhaps you could detail what relationships exist, if any.

I would have expected there to be a 1:M between staff and training, since
each staff member could go on many training courses.
My VB skills are virtually non existent.

Please help

Ian

Keith.
www.keithwilby.com
 
G

Guest

Sorry, yes i do have a 1 to many relationship staff being on the 1 side as
you mentioned.

The forms at the moment are not linked. What I meant was I would like a
button on my main staff details form to open the training record form for the
staff member I am currently viewing.

Does that make sense. Just in case if I was looking at John Smith's
personal details and decided I wanted to view his training record, then I
would like to be able to click a button which will open the training record
form to his own record.

Thanks for helping me.
 
K

Keith Wilby

NoviceIan said:
Sorry, yes i do have a 1 to many relationship staff being on the 1 side as
you mentioned.

The forms at the moment are not linked. What I meant was I would like a
button on my main staff details form to open the training record form for
the
staff member I am currently viewing.

Does that make sense. Just in case if I was looking at John Smith's
personal details and decided I wanted to view his training record, then I
would like to be able to click a button which will open the training
record
form to his own record.

Thanks for helping me.

Ah right. Use the value from a PK text box on your main form to filter the
form being opened (untested):

DoCmd.OpenForm "frmTraining",,,"[ForiegnKeyFieldName] = " & Me.txtPrimaryKey

HTH - Keith.
www.keithwilby.com
 
G

Guest

I've tried messing around with that code but my VB skills are non existent
I'm affraid i use macros where ever possible which are generally fine for my
purposes.

Could you please help me a little more sorry to be a dunse.

The From I'm opening from is Staff Details
The form I wish to open is Training Mainform
The linked fields are Staff Number

Keith Wilby said:
NoviceIan said:
Sorry, yes i do have a 1 to many relationship staff being on the 1 side as
you mentioned.

The forms at the moment are not linked. What I meant was I would like a
button on my main staff details form to open the training record form for
the
staff member I am currently viewing.

Does that make sense. Just in case if I was looking at John Smith's
personal details and decided I wanted to view his training record, then I
would like to be able to click a button which will open the training
record
form to his own record.

Thanks for helping me.

Ah right. Use the value from a PK text box on your main form to filter the
form being opened (untested):

DoCmd.OpenForm "frmTraining",,,"[ForiegnKeyFieldName] = " & Me.txtPrimaryKey

HTH - Keith.
www.keithwilby.com
 
K

Keith Wilby

NoviceIan said:
I've tried messing around with that code but my VB skills are non existent
I'm affraid i use macros where ever possible which are generally fine for
my
purposes.

Could you please help me a little more sorry to be a dunse.

The From I'm opening from is Staff Details
The form I wish to open is Training Mainform
The linked fields are Staff Number

All you need to do is substitue the generic object names I've supplied with
your actual names:

DoCmd.OpenForm "Training Mainform",,,"[Staff Number] = " & Me.txtPrimaryKey

txtPrimaryKey is the name of the *control* which is bound to your main
table's Primary Key (ie, its *control* name and not the *field* name,
although Access may have made them the same). Also make sure you have those
three commas after the form name. Post back if you're still stuck.

Keith.
 
G

Guest

Its "Method or data member not found" and highlights the primarykey text in
the code.

Keith Wilby said:
NoviceIan said:
I've tried messing around with that code but my VB skills are non existent
I'm affraid i use macros where ever possible which are generally fine for
my
purposes.

Could you please help me a little more sorry to be a dunse.

The From I'm opening from is Staff Details
The form I wish to open is Training Mainform
The linked fields are Staff Number

All you need to do is substitue the generic object names I've supplied with
your actual names:

DoCmd.OpenForm "Training Mainform",,,"[Staff Number] = " & Me.txtPrimaryKey

txtPrimaryKey is the name of the *control* which is bound to your main
table's Primary Key (ie, its *control* name and not the *field* name,
although Access may have made them the same). Also make sure you have those
three commas after the form name. Post back if you're still stuck.

Keith.
 
K

Keith Wilby

NoviceIan said:
Its "Method or data member not found" and highlights the primarykey text
in
the code.

I've just tested my code on a very simple setup and it works. Can you post
the code that fails please?
 
G

Guest

You need to substitute txtPrimaryKey for the name of your textbox/combobox
that uniquely identifies the record. If you right click the textbox, click
properties, and click the "other" tab, you can see the name. You might habe
to surround the name in [] brackets if it has a space in it.

NoviceIan said:
Its "Method or data member not found" and highlights the primarykey text in
the code.

Keith Wilby said:
NoviceIan said:
I've tried messing around with that code but my VB skills are non existent
I'm affraid i use macros where ever possible which are generally fine for
my
purposes.

Could you please help me a little more sorry to be a dunse.

The From I'm opening from is Staff Details
The form I wish to open is Training Mainform
The linked fields are Staff Number

All you need to do is substitue the generic object names I've supplied with
your actual names:

DoCmd.OpenForm "Training Mainform",,,"[Staff Number] = " & Me.txtPrimaryKey

txtPrimaryKey is the name of the *control* which is bound to your main
table's Primary Key (ie, its *control* name and not the *field* name,
although Access may have made them the same). Also make sure you have those
three commas after the form name. Post back if you're still stuck.

Keith.
 

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