P
Pat Dools
Hello,
I would like to implement code that will disable controls on a given form
only for the existing records. I have a form that opens on database startup
with the following code behind a Command Button to allow me to open a blank
form ("fScrEligCriteria"):
Private Sub CommandNewPatient_Click()
On Error GoTo Err_CommandNewPatient_Click
DoCmd.OpenForm "fScrEligCriteria"
DoCmd.GoToRecord , , acNewRec
Exit_CommandNewPatient_Click:
Exit Sub
Err_CommandNewPatient_Click:
MsgBox Err.Description
Resume Exit_CommandNewPatient_Click
End Sub
I have the following code running, but unfortunately, it disables the
controls for New Records also. The code runs on the 'OnCurrent' property of
the Form where 'secureform' is a check box field that is checked off by the
data entry person once they are done entering data using this form. Since it
is on the 'OnCurrent' property of the form, this code is running FIRST, and
then the 'Sub CommandNewPatient_Click()' (above) code is running and it gives
the error: 'You can't use the GoToRecord Action or method on an object in
Design view'. Here is the code:
Private Sub Form_Current()
Dim blnLock As Boolean
If Me.NewRecord = False Then
blnLock = (Me.secureform.Value <> True)
Me.secureform.Enabled = blnLock
Me.FrameIncl1.Enabled = blnLock
Me.FrameIncl2.Enabled = blnLock
Me.FrameIncl3.Enabled = blnLock
Me.FrameIncl4.Enabled = blnLock
Me.FrameIncl5.Enabled = blnLock
Me.FrameIncl6.Enabled = blnLock
Me.FrameIncl7.Enabled = blnLock
Me.FrameIncl8.Enabled = blnLock
Me.FrameIncl9.Enabled = blnLock
Me.FrameIncl10.Enabled = blnLock
Me.FrameIncl11.Enabled = blnLock
Me.FrameIncl12.Enabled = blnLock
Me.FrameIncl13.Enabled = blnLock
Me.FrameIncl14.Enabled = blnLock
End If
End Sub
Since I am entering this form via a Command button on the database's startup
form, can I not evaluate NewRecord status in the 'OnCurrent' event of the
form ("fScrEligCriteria") that is being opened by the Command Button on the
database startup form?
Thanks.
I would like to implement code that will disable controls on a given form
only for the existing records. I have a form that opens on database startup
with the following code behind a Command Button to allow me to open a blank
form ("fScrEligCriteria"):
Private Sub CommandNewPatient_Click()
On Error GoTo Err_CommandNewPatient_Click
DoCmd.OpenForm "fScrEligCriteria"
DoCmd.GoToRecord , , acNewRec
Exit_CommandNewPatient_Click:
Exit Sub
Err_CommandNewPatient_Click:
MsgBox Err.Description
Resume Exit_CommandNewPatient_Click
End Sub
I have the following code running, but unfortunately, it disables the
controls for New Records also. The code runs on the 'OnCurrent' property of
the Form where 'secureform' is a check box field that is checked off by the
data entry person once they are done entering data using this form. Since it
is on the 'OnCurrent' property of the form, this code is running FIRST, and
then the 'Sub CommandNewPatient_Click()' (above) code is running and it gives
the error: 'You can't use the GoToRecord Action or method on an object in
Design view'. Here is the code:
Private Sub Form_Current()
Dim blnLock As Boolean
If Me.NewRecord = False Then
blnLock = (Me.secureform.Value <> True)
Me.secureform.Enabled = blnLock
Me.FrameIncl1.Enabled = blnLock
Me.FrameIncl2.Enabled = blnLock
Me.FrameIncl3.Enabled = blnLock
Me.FrameIncl4.Enabled = blnLock
Me.FrameIncl5.Enabled = blnLock
Me.FrameIncl6.Enabled = blnLock
Me.FrameIncl7.Enabled = blnLock
Me.FrameIncl8.Enabled = blnLock
Me.FrameIncl9.Enabled = blnLock
Me.FrameIncl10.Enabled = blnLock
Me.FrameIncl11.Enabled = blnLock
Me.FrameIncl12.Enabled = blnLock
Me.FrameIncl13.Enabled = blnLock
Me.FrameIncl14.Enabled = blnLock
End If
End Sub
Since I am entering this form via a Command button on the database's startup
form, can I not evaluate NewRecord status in the 'OnCurrent' event of the
form ("fScrEligCriteria") that is being opened by the Command Button on the
database startup form?
Thanks.