P
Pat Dools
Hello,
In my clinical research application, I am attempting to have users fill in a
'Patient Info.' form with 8 total fields. The first 3 fields (ID, intials,
site) are stored in one table that can be added to. There are 3 more fields
on the 'Patient Info.' form that are populated by a combo box that looks up
to another table which contains a set of records related to the forms that
are filled out for these patients (Study Phase, Form Name, Form Page Number).
These 2 tables are the 'Patient Info.' form's Control Source. Finally,
there are 2 more fields on the 'Patient Info.' form that have to do with what
Day of Study they are in (Study Day, and Study Day Flag) that are populated
by combo boxes that have Value Lists supply the potential values and are not
bound to a specific table.
Once these fields are populated, the following code is executed behind a
Command Button to open the 'Patient Status' form:
Private Sub CommandGoToPatientStatus_Click()
On Error GoTo Err_CommandGoToPatientStatus_Click
If MsgBox("Click Yes for data entry or No for QC", vbYesNo) = vbYes Then
DoCmd.OpenForm "FCRFStatus", , , , acAdd
'Call SetAutoValues(Forms(Me!SelectForm))
Else
DoCmd.OpenForm "FCRFStatus", , , "[id] = Forms.fEnterPatientInfo.id"
End If
Exit_CommandGoToPatientStatus_Click:
Exit Sub
Err_CommandGoToPatientStatus_Click:
MsgBox Err.Description
Resume Exit_CommandGoToPatientStatus_Click
End Sub
Then the 'Patient Status' form opens with this code in the form's 'On
Current' Event:
Private Sub Form_Current()
If Me.NewRecord Then
Call SetAutoValues(Me)
End If
End Sub
Where 'SetAutoValues(Me)' is:
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
!studyphase = Forms!fEnterPatientInfo!studyphase
!CRFname = Forms!fEnterPatientInfo!CRFname
!pagenum = Forms!fEnterPatientInfo!pagenum
!cyclenum = Forms!fEnterPatientInfo!CboCycle
!studyday = Forms!fEnterPatientInfo!CboStudyDay
!studydayflag = Forms!fEnterPatientInfo!CboStudyDayFlag
End With
Exit_SetAutoValues:
Exit Sub
SetAutoValues_err:
MsgBox Err.Description
Resume Next
End Sub
I want be able to go to either new records or find existing ones, but when
this set of code executes, it always opens the 'Patient Status' form and
auto-populates the 8 fields from the 'Patient Info.' form as if it were a new
record.
For the table underneath the 'Patient Status' form, 5 of the 8 fields
inherited from the 'Patient Info.' form combine to form that table's Primary
Key. Is this why I cannot be brought to a specific record-- or at least be
brought to the records where there is a match on the 'id' field (see code
from above):
DoCmd.OpenForm "FCRFStatus", , , "[id] = Forms.fEnterPatientInfo.id"
Again, ideally, I would like to be brought to the 'Patient Statys' record
that matches the 8 fields I fill out on the 'Patient Info.' record, so the
data entry person can update that record as needed.
Thanks,
In my clinical research application, I am attempting to have users fill in a
'Patient Info.' form with 8 total fields. The first 3 fields (ID, intials,
site) are stored in one table that can be added to. There are 3 more fields
on the 'Patient Info.' form that are populated by a combo box that looks up
to another table which contains a set of records related to the forms that
are filled out for these patients (Study Phase, Form Name, Form Page Number).
These 2 tables are the 'Patient Info.' form's Control Source. Finally,
there are 2 more fields on the 'Patient Info.' form that have to do with what
Day of Study they are in (Study Day, and Study Day Flag) that are populated
by combo boxes that have Value Lists supply the potential values and are not
bound to a specific table.
Once these fields are populated, the following code is executed behind a
Command Button to open the 'Patient Status' form:
Private Sub CommandGoToPatientStatus_Click()
On Error GoTo Err_CommandGoToPatientStatus_Click
If MsgBox("Click Yes for data entry or No for QC", vbYesNo) = vbYes Then
DoCmd.OpenForm "FCRFStatus", , , , acAdd
'Call SetAutoValues(Forms(Me!SelectForm))
Else
DoCmd.OpenForm "FCRFStatus", , , "[id] = Forms.fEnterPatientInfo.id"
End If
Exit_CommandGoToPatientStatus_Click:
Exit Sub
Err_CommandGoToPatientStatus_Click:
MsgBox Err.Description
Resume Exit_CommandGoToPatientStatus_Click
End Sub
Then the 'Patient Status' form opens with this code in the form's 'On
Current' Event:
Private Sub Form_Current()
If Me.NewRecord Then
Call SetAutoValues(Me)
End If
End Sub
Where 'SetAutoValues(Me)' is:
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
!studyphase = Forms!fEnterPatientInfo!studyphase
!CRFname = Forms!fEnterPatientInfo!CRFname
!pagenum = Forms!fEnterPatientInfo!pagenum
!cyclenum = Forms!fEnterPatientInfo!CboCycle
!studyday = Forms!fEnterPatientInfo!CboStudyDay
!studydayflag = Forms!fEnterPatientInfo!CboStudyDayFlag
End With
Exit_SetAutoValues:
Exit Sub
SetAutoValues_err:
MsgBox Err.Description
Resume Next
End Sub
I want be able to go to either new records or find existing ones, but when
this set of code executes, it always opens the 'Patient Status' form and
auto-populates the 8 fields from the 'Patient Info.' form as if it were a new
record.
For the table underneath the 'Patient Status' form, 5 of the 8 fields
inherited from the 'Patient Info.' form combine to form that table's Primary
Key. Is this why I cannot be brought to a specific record-- or at least be
brought to the records where there is a match on the 'id' field (see code
from above):
DoCmd.OpenForm "FCRFStatus", , , "[id] = Forms.fEnterPatientInfo.id"
Again, ideally, I would like to be brought to the 'Patient Statys' record
that matches the 8 fields I fill out on the 'Patient Info.' record, so the
data entry person can update that record as needed.
Thanks,