L
laura.dodge
Hi, I've created a database to manage the results of a very lengthy
questionnaire. Due to size constraints, I have five tables that hold
my data. Each field in each table has a corresponding control in one
of five corresponding forms. The idea is for the user to be able to
begin on form1 (frmB101) and navigate through the other four forms. At
the end, she should be able to go back to form1 and start entering
data from another participant. I've put command buttons on each form
to close the current form and open the next form. On load, the
previous form will pass the subject ID number to the next form. The
subject ID is my primary key, and is locked on forms 2-5. All of this
worked wonderfully for record 1. At form5 I can click the 'New'
button, which will take me to form1, record 2. The problem begins when
I try to navigate to form2, record2. Access will take me to form2, but
it will be record1. Because of the passing of the ID number, this
returns a blank record1 with the new ID number, so it's overwritten my
previous record. Adding code to go to a new record on load doesn't
work, because each time I navigate to a new form, the record number
increases by 1, which leaves me with duplicate primary key values.
Does anyone have any ideas on how to tell Access to stay on record2
for all the forms until I get to the end? I've included some of my
code for form1 (frmB101) below in case that is helpful. Thanks so much
for any suggestions!
Option Compare Database
Private Sub cmdB101_Click()
If Me.Dirty Then Me.Dirty = False
DoCmd.OpenForm "frmB312", OpenArgs:=Me.B101
DoCmd.GoToRecord , , acNewRec
DoCmd.Close acForm, Me.Name, acSaveNo
End Sub
Private Sub cmdB101New_Click()
If Me.Dirty Then Me.Dirty = False
DoCmd.OpenForm "frmB101"
DoCmd.GoToRecord , , acNewRec
End Sub
questionnaire. Due to size constraints, I have five tables that hold
my data. Each field in each table has a corresponding control in one
of five corresponding forms. The idea is for the user to be able to
begin on form1 (frmB101) and navigate through the other four forms. At
the end, she should be able to go back to form1 and start entering
data from another participant. I've put command buttons on each form
to close the current form and open the next form. On load, the
previous form will pass the subject ID number to the next form. The
subject ID is my primary key, and is locked on forms 2-5. All of this
worked wonderfully for record 1. At form5 I can click the 'New'
button, which will take me to form1, record 2. The problem begins when
I try to navigate to form2, record2. Access will take me to form2, but
it will be record1. Because of the passing of the ID number, this
returns a blank record1 with the new ID number, so it's overwritten my
previous record. Adding code to go to a new record on load doesn't
work, because each time I navigate to a new form, the record number
increases by 1, which leaves me with duplicate primary key values.
Does anyone have any ideas on how to tell Access to stay on record2
for all the forms until I get to the end? I've included some of my
code for form1 (frmB101) below in case that is helpful. Thanks so much
for any suggestions!
Option Compare Database
Private Sub cmdB101_Click()
If Me.Dirty Then Me.Dirty = False
DoCmd.OpenForm "frmB312", OpenArgs:=Me.B101
DoCmd.GoToRecord , , acNewRec
DoCmd.Close acForm, Me.Name, acSaveNo
End Sub
Private Sub cmdB101New_Click()
If Me.Dirty Then Me.Dirty = False
DoCmd.OpenForm "frmB101"
DoCmd.GoToRecord , , acNewRec
End Sub