Hi Scott,
I don't know if you're even still needing this, but this is the code I use
in order to 'carry over' fields from one form to another:
I start by putting the following in the Form's 'On Current' Event:
Private Sub Form_Current()
If Me.NewRecord Then
Call SetAutoValues(Me)
Else
Call LockControls(Me)
End If
End Sub
which, if a New Record calls the following Module:
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
or if it is NOT a New Record, and you want to 'Lock' already existing
records to prevent data changes while viewing them. This code basically
locks all the different types of controls that could be on a form, and gives
the option to NOT lock certain controls by setting the 'Tag' property of that
control. Here is that code:
Public Sub LockControls(frm As Form)
On Error Resume Next
Dim ctl As Control
For Each ctl In frm.Controls
With ctl
Select Case .ControlType
Case acTextBox
ctl.Locked = True
Case acComboBox
If ctl.Tag = 2 Then
ctl.Locked = False
Else
ctl.Locked = True
End If
Case acListBox
ctl.Locked = True
Case acCheckBox
ctl.Locked = True
Case acToggleButton
ctl.Locked = True
Case acCommandButton
If ctl.Tag = 2 Then
ctl.Enabled = False
Else
ctl.Enalbled = True
End If
Case acSubform
ctl.Locked = True
Case acOptionGroup
ctl.Locked = True
Case acOptionButton
ctl.Locked = True
End Select
End With
Next ctl
Set ctl = Nothing
Set frm = Nothing
End Sub
HTH, Patrick