I currently have form, which on open sets the enable and locked parameters of feilds on the form based on certain record criteria. I.E. if x=1, then feild1.locked = true, else feild1.locked = false. This works fine for the first record, but when the 2nd record is selected the locked and enabled values are based on the data in the ist record as opposed to the active record.
------------------------
Private Sub Form_Open(CANCEL As Integer) ' Do this when form opens.
On Error GoTo err_no_records
DoCmd.MoveSize 0, 0
DoCmd.applyfilter , "PRINTED <> -1"
lngred = RGB(255, 0, 0)
lngBlack = RGB(0, 0, 0)
lngyellow = RGB(255, 255, 0) ' Used to set color of updatable feilds
lngwhite = RGB(255, 255, 255)
Dim strUserName As String
Dim StrFullName As String
strUserName = ap_GetUserName()
If (strUserName = "dkape1"
Then
StrFullName = "Douglas Kapell"
DoCmd.applyfilter , "DATA_PROC = 3"
DoCmd.applyfilter , "PRINTED <> -1"
Me.Frame_data.Enabled = True
Me.data_cmt.Enabled = True
Me.Frame_data.Locked = False
Me.data_cmt.Locked = False
Me.data_cmt.BackColor = lngyellow
Me.data_label.BackColor = lngyellow
--------------------------------------------
So I think what I need to do is have the code rerun on each new record. Am I on the right track, and if so how is this done.
------------------------
Private Sub Form_Open(CANCEL As Integer) ' Do this when form opens.
On Error GoTo err_no_records
DoCmd.MoveSize 0, 0
DoCmd.applyfilter , "PRINTED <> -1"
lngred = RGB(255, 0, 0)
lngBlack = RGB(0, 0, 0)
lngyellow = RGB(255, 255, 0) ' Used to set color of updatable feilds
lngwhite = RGB(255, 255, 255)
Dim strUserName As String
Dim StrFullName As String
strUserName = ap_GetUserName()
If (strUserName = "dkape1"
StrFullName = "Douglas Kapell"
DoCmd.applyfilter , "DATA_PROC = 3"
DoCmd.applyfilter , "PRINTED <> -1"
Me.Frame_data.Enabled = True
Me.data_cmt.Enabled = True
Me.Frame_data.Locked = False
Me.data_cmt.Locked = False
Me.data_cmt.BackColor = lngyellow
Me.data_label.BackColor = lngyellow
--------------------------------------------
So I think what I need to do is have the code rerun on each new record. Am I on the right track, and if so how is this done.