P
Pat Dools
Hello,
I have a strange situation in which a New Record is called up in certain
situations, but does not accept any new data. The New Record is called by
clicking on a Command Button on a form. If it is clicked right after you
have entered one record using that form ('FCycDrugAdminAmplimex'), and you
want to enter another, that works fine. What doesn't work is when one goes
back into an existing record using this form ('FCycDrugAdminAmplimex'), and
then clicks on the 'New Record' Command Button. The new form opens, and
'stepping thru' the code, it clearly calls a New Record, fills out the Header
field info. executing 'SetAutoValues(Me)', and clearly does NOT call the sub
to lock the controls on the form LockControls(Me). I am baffled, but the
blank form in this situation is behaving as if it is 'Locked', it is as if it
is 'inheriting' the Lock Records charactieristic that all records that are
input into my database have after entry. I have ensure that I do NOT have
'Record Locks on the Form Property set to 'Yes', nor are any of the fields
'Locked' Property set to 'Yes'. What am I missing here?
Here is the code behind the Command Button:
Private Sub CommandOpenNewRecord_Click()
DoCmd.OpenForm "FCycDrugAdminAmplimex", acNormal
DoCmd.GoToRecord acDataForm, "FCycDrugAdminAmplimex", acNewRec
DoCmd.GoToControl "cyclenum"
End Sub
Once it hits 'acNewRec', then this code is called on the Form's OnCurrent
Event:
Private Sub Form_Current()
If Me.NewRecord Then
Call SetAutoValues(Me)
Else
Call LockControls(Me)
End If
End Sub
Sub SetAutoValues(frm As Form)
On Error GoTo SetAutoValues_err
' Set Automatic Values in each form in series
' Add as many fields as necessary (make sure each field has the same
name on EVERY form)
With frm
!id = Forms!fEnterPatientInfo!id
!ptin = Forms!fEnterPatientInfo!ptin
!site = Forms!fEnterPatientInfo!site
End With
SetAutoValues_err:
'MsgBox Err.Description
Resume Next
End Sub
Thank you.
I have a strange situation in which a New Record is called up in certain
situations, but does not accept any new data. The New Record is called by
clicking on a Command Button on a form. If it is clicked right after you
have entered one record using that form ('FCycDrugAdminAmplimex'), and you
want to enter another, that works fine. What doesn't work is when one goes
back into an existing record using this form ('FCycDrugAdminAmplimex'), and
then clicks on the 'New Record' Command Button. The new form opens, and
'stepping thru' the code, it clearly calls a New Record, fills out the Header
field info. executing 'SetAutoValues(Me)', and clearly does NOT call the sub
to lock the controls on the form LockControls(Me). I am baffled, but the
blank form in this situation is behaving as if it is 'Locked', it is as if it
is 'inheriting' the Lock Records charactieristic that all records that are
input into my database have after entry. I have ensure that I do NOT have
'Record Locks on the Form Property set to 'Yes', nor are any of the fields
'Locked' Property set to 'Yes'. What am I missing here?
Here is the code behind the Command Button:
Private Sub CommandOpenNewRecord_Click()
DoCmd.OpenForm "FCycDrugAdminAmplimex", acNormal
DoCmd.GoToRecord acDataForm, "FCycDrugAdminAmplimex", acNewRec
DoCmd.GoToControl "cyclenum"
End Sub
Once it hits 'acNewRec', then this code is called on the Form's OnCurrent
Event:
Private Sub Form_Current()
If Me.NewRecord Then
Call SetAutoValues(Me)
Else
Call LockControls(Me)
End If
End Sub
Sub SetAutoValues(frm As Form)
On Error GoTo SetAutoValues_err
' Set Automatic Values in each form in series
' Add as many fields as necessary (make sure each field has the same
name on EVERY form)
With frm
!id = Forms!fEnterPatientInfo!id
!ptin = Forms!fEnterPatientInfo!ptin
!site = Forms!fEnterPatientInfo!site
End With
SetAutoValues_err:
'MsgBox Err.Description
Resume Next
End Sub
Thank you.