P
Pat Dools
Hello,
I have a simply database application where one can fill out a 'Patient
Info.' box with basic Patient ID info. (ID, initials, and site #) and then
have that info. auto-populated in a 'Patient Status' form once they click on
a Command Button on the 'Patient Info.' form. There are two Command Buttons,
actually at the bottom of the 'Patient Info' form-- one to open an existing
record, and one to open a New Record.
Here is the code used to open the 'Patient Status' form using the one of the
forementioned Command Button when I want the user to only be brought to an
existing record:
Private Sub CommandGoToPatientStatus_Click()
On Error GoTo Err_CommandGoToPatientStatus_Click
DoCmd.OpenForm "FCRFStatus", , , "[id] = Forms.fEnterPatientInfo.id"
Exit_CommandGoToPatientStatus_Click:
Exit Sub
Err_CommandGoToPatientStatus_Click:
MsgBox Err.Description
Resume Exit_CommandGoToPatientStatus_Click
End Sub
This is the code behind the other Command Button I have when I want to open
a NEW 'Patient Status' record:
Private Sub CommandGoToPatientStatus_Click()
On Error GoTo Err_CommandGoToPatientStatus_Click
DoCmd.OpenForm "FCRFStatus", , , , acAdd
Exit_CommandGoToPatientStatus_Click:
Exit Sub
Err_CommandGoToPatientStatus_Click:
MsgBox Err.Description
Resume Exit_CommandGoToPatientStatus_Click
End Sub
In the 'Patient Status' form's 'On Current:' Event, I have the following code:
Private Sub Form_Current()
If Me.NewRecord Then
Call SetAutoValues(Me)
Else
DoCmd.OpenForm "FCRFStatus", , , "[id] = Forms.fEnterPatientInfo.id"
End If
End Sub
Where SetAutoValues(Me) looks like:
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
Exit_SetAutoValues:
Exit Sub
SetAutoValues_err:
MsgBox Err.Description
Resume Next
End Sub
I have stepped thru the code, and the 'If Me. NewRecord' is always seen as
true. What am I missing here so that one Command button will open a New
'Patient Status' record and the other Command button will find an existing
record?
Thanks.
I have a simply database application where one can fill out a 'Patient
Info.' box with basic Patient ID info. (ID, initials, and site #) and then
have that info. auto-populated in a 'Patient Status' form once they click on
a Command Button on the 'Patient Info.' form. There are two Command Buttons,
actually at the bottom of the 'Patient Info' form-- one to open an existing
record, and one to open a New Record.
Here is the code used to open the 'Patient Status' form using the one of the
forementioned Command Button when I want the user to only be brought to an
existing record:
Private Sub CommandGoToPatientStatus_Click()
On Error GoTo Err_CommandGoToPatientStatus_Click
DoCmd.OpenForm "FCRFStatus", , , "[id] = Forms.fEnterPatientInfo.id"
Exit_CommandGoToPatientStatus_Click:
Exit Sub
Err_CommandGoToPatientStatus_Click:
MsgBox Err.Description
Resume Exit_CommandGoToPatientStatus_Click
End Sub
This is the code behind the other Command Button I have when I want to open
a NEW 'Patient Status' record:
Private Sub CommandGoToPatientStatus_Click()
On Error GoTo Err_CommandGoToPatientStatus_Click
DoCmd.OpenForm "FCRFStatus", , , , acAdd
Exit_CommandGoToPatientStatus_Click:
Exit Sub
Err_CommandGoToPatientStatus_Click:
MsgBox Err.Description
Resume Exit_CommandGoToPatientStatus_Click
End Sub
In the 'Patient Status' form's 'On Current:' Event, I have the following code:
Private Sub Form_Current()
If Me.NewRecord Then
Call SetAutoValues(Me)
Else
DoCmd.OpenForm "FCRFStatus", , , "[id] = Forms.fEnterPatientInfo.id"
End If
End Sub
Where SetAutoValues(Me) looks like:
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
Exit_SetAutoValues:
Exit Sub
SetAutoValues_err:
MsgBox Err.Description
Resume Next
End Sub
I have stepped thru the code, and the 'If Me. NewRecord' is always seen as
true. What am I missing here so that one Command button will open a New
'Patient Status' record and the other Command button will find an existing
record?
Thanks.