P
Pat Dools
Hello,
I have the following code behind a Command Button that is supposed to:
1) Save the current record
2) Open a different form
3) Allow me to enter a New record on the form opened in #2
Here's the code:
Private Sub CommandGemD08_Click()
DoCmd.Save acForm, "fCycDoseVitalGemCyc01D01"
DoCmd.OpenForm "fCycDoseVitalGemCyc02D01", acNormal
DoCmd.GoToRecord acDataForm, "fCycDoseVitalGemCyc02D01", acNewRec
DoCmd.Close acForm, "fCycDoseVitalGemCyc01D01"
End Sub
In debugging this code, it clearly skips over the line where a New Record is
brought up for the new Form ("fCycDoseVitalGemCyc02D01"):
DoCmd.GoToRecord acDataForm, "fCycDoseVitalGemCyc02D01", acNewRec
It does open the form I want it to open, but I have code that checks if you
are opening a new record or not on every Form's 'OnCurrent' event:
Private Sub Form_Current()
If Me.NewRecord Then
Call SetAutoValues(Me)
Else
Call LockControls(Me)
End If
End Sub
If it's new, 'SetAutoValues' automatically fills in some header fields
identifying the current patient record that you are entering (e.g., ID,
initials, etc.). If it is NOT new, then 'LockControls' locks down all
controls on that record to prevent our data entry people from being able to
go back and edit records that have already been entered. So, by skipping
this line:
DoCmd.GoToRecord acDataForm, "fCycDoseVitalGemCyc02D01", acNewRec
the form that is opened is not treated as a New Record, and thus all
controls on the form (Text Boxes, Combo Boxes) used to enter data into the
underlying table are 'locked'. Why is it skipping the 'DoCmd...' code that
creates a New Record and how can I adjust it to have a New Record brought up?
Thanks.
I have the following code behind a Command Button that is supposed to:
1) Save the current record
2) Open a different form
3) Allow me to enter a New record on the form opened in #2
Here's the code:
Private Sub CommandGemD08_Click()
DoCmd.Save acForm, "fCycDoseVitalGemCyc01D01"
DoCmd.OpenForm "fCycDoseVitalGemCyc02D01", acNormal
DoCmd.GoToRecord acDataForm, "fCycDoseVitalGemCyc02D01", acNewRec
DoCmd.Close acForm, "fCycDoseVitalGemCyc01D01"
End Sub
In debugging this code, it clearly skips over the line where a New Record is
brought up for the new Form ("fCycDoseVitalGemCyc02D01"):
DoCmd.GoToRecord acDataForm, "fCycDoseVitalGemCyc02D01", acNewRec
It does open the form I want it to open, but I have code that checks if you
are opening a new record or not on every Form's 'OnCurrent' event:
Private Sub Form_Current()
If Me.NewRecord Then
Call SetAutoValues(Me)
Else
Call LockControls(Me)
End If
End Sub
If it's new, 'SetAutoValues' automatically fills in some header fields
identifying the current patient record that you are entering (e.g., ID,
initials, etc.). If it is NOT new, then 'LockControls' locks down all
controls on that record to prevent our data entry people from being able to
go back and edit records that have already been entered. So, by skipping
this line:
DoCmd.GoToRecord acDataForm, "fCycDoseVitalGemCyc02D01", acNewRec
the form that is opened is not treated as a New Record, and thus all
controls on the form (Text Boxes, Combo Boxes) used to enter data into the
underlying table are 'locked'. Why is it skipping the 'DoCmd...' code that
creates a New Record and how can I adjust it to have a New Record brought up?
Thanks.