Hello everyone...
I have a form that I want to copy selected field values to another form & subform.
I have no problem copying some field values to frmEndorsement... but I can't figure out how
to copy the other field values to the frmEndorsementSubform. I tried several ways but I'm still
on a dead end...
Here's the actual example...
I want to transfer some selected fields from "frmEncounter" to "frmEndorsement" & "frmEndorsementSubform"
In my frmEncounter, I have these fields...
mdsunit, patientID, lastname, firstname, pcp, & encountID ( EncountID is autonumber-PK)
In my frmEndorsement, I have...
patientID, lastname, firstname
& in my frmEndorsementSubform, I have...
pcp, msdunit, & encountID ( encountID is numeric-long integer )
There is a link master-child field between frmEndorsement & frmEndorsementSubform which is patientID.
and below is my code that I got from Ms. Candace Tripp...
Thanks in advance... Jim
I have a form that I want to copy selected field values to another form & subform.
I have no problem copying some field values to frmEndorsement... but I can't figure out how
to copy the other field values to the frmEndorsementSubform. I tried several ways but I'm still
on a dead end...
Here's the actual example...
I want to transfer some selected fields from "frmEncounter" to "frmEndorsement" & "frmEndorsementSubform"
In my frmEncounter, I have these fields...
mdsunit, patientID, lastname, firstname, pcp, & encountID ( EncountID is autonumber-PK)
In my frmEndorsement, I have...
patientID, lastname, firstname
& in my frmEndorsementSubform, I have...
pcp, msdunit, & encountID ( encountID is numeric-long integer )
There is a link master-child field between frmEndorsement & frmEndorsementSubform which is patientID.
and below is my code that I got from Ms. Candace Tripp...
Thanks in advance... Jim
Code:
[left]Private Sub cmdcopy_Click()
On Error Resume Next
Dim bOpen As Boolean
Dim ctl As Control
Dim frm2 As Form
Dim ctl2 As Control
' check to see Endorsement Data Entry is open
bOpen = IsOpen("frmEndorsement")
If Not bOpen Then
' open form
DoCmd.OpenForm "frmEndorsement"
End If
Set frm2 = Forms!frmEndorsement
' send data to frmEndorsement
' look at each control on frmlEncounter
For Each ctl In Me.Controls
' only look at combo boxes and text boxes
If TypeOf ctl Is TextBox Or TypeOf ctl Is ComboBox Then
' now look at each control on frmEndorsement
For Each ctl2 In frm2
If TypeOf ctl2 Is TextBox Or TypeOf ctl2 Is ComboBox Then
' if the control names are the same,
' set the value to that control on frmEndorsement
If ctl.name = ctl2.name Then
ctl2.Value = ctl.Value
End If
End If
Next ctl2
End If
Next ctl
Me.PCP = Forms!frmEndorsement!frmEndorsementSubform!PCP
Me.EncountID = Forms!frmEndorsement!frmEndorsementSubform!EncountID
Me.mdsunit = Forms!frmEndorsement!frmEndorsementSubform!mdsunit
End Sub[/left]