T
tudogman via AccessMonster.com
I’m relatively new to Access coding and I’m running just beyond the limits of
my knowledge.
I’ve got a shared Access 97 database with a module that returns the wrong
answer and/or locks the field that should not be locked.
The form is loaded from another form with the conditions set so that it will
display based on the Incident Number (incidentno).
Right now, I’ve got a MsgBox that will tell me the condition of the CheckBox
found in the DLookup when the form loads.
I can’t check the condition of the checkbox from the form as it is in a
different, password protected, form and not all users have access to.
Here’s the code:
Private Sub Form_Current()
'This subroutine will check the TBLincedent.Prelimorfinal field to see if it
is checked. If it is, it will
'lock the field so that a user cannot change the date.
'Set the initial definitions
Dim TargetComplete As Variant
Dim txtTargetComplete As String
Dim incidentno As Long
Dim txtincidentno As String
Dim TBLincident As Recordset
Dim Prelimorfinal As CheckBox
Dim inc As Variant 'Will determine the Incident Number
Dim chk As Variant 'Will be the result of combining TBLIncident &
Prelimorfinal
'find the Incident Number
inc = Forms![frmactionseditc].incidentno
'-----------------------------
' Do the DLookUp
chk = DLookup("[Prelimorfinal]", "TBLincident", "[txtTargetComplete]='" & _
Forms![frmactionseditc].[txtTargetComplete] & "'")
If chk = -1 Then
MsgBox "The box is " & chk & "!" & vbCrLf & " The Incident No is: " & inc,
vbOKOnly, "OK"
Me![txtTargetComplete].Locked = True
Me![txtTargetComplete].Enabled = False
Else
MsgBox "The box is " & chk & "!" & vbCrLf & "The Incident No is: " & inc,
vbOKOnly, "OK"
Me![txtTargetComplete].Enabled = True
Me![txtTargetComplete].Locked = False
End If
End Sub
What the HECK am I doing wrong!?
my knowledge.
I’ve got a shared Access 97 database with a module that returns the wrong
answer and/or locks the field that should not be locked.
The form is loaded from another form with the conditions set so that it will
display based on the Incident Number (incidentno).
Right now, I’ve got a MsgBox that will tell me the condition of the CheckBox
found in the DLookup when the form loads.
I can’t check the condition of the checkbox from the form as it is in a
different, password protected, form and not all users have access to.
Here’s the code:
Private Sub Form_Current()
'This subroutine will check the TBLincedent.Prelimorfinal field to see if it
is checked. If it is, it will
'lock the field so that a user cannot change the date.
'Set the initial definitions
Dim TargetComplete As Variant
Dim txtTargetComplete As String
Dim incidentno As Long
Dim txtincidentno As String
Dim TBLincident As Recordset
Dim Prelimorfinal As CheckBox
Dim inc As Variant 'Will determine the Incident Number
Dim chk As Variant 'Will be the result of combining TBLIncident &
Prelimorfinal
'find the Incident Number
inc = Forms![frmactionseditc].incidentno
'-----------------------------
' Do the DLookUp
chk = DLookup("[Prelimorfinal]", "TBLincident", "[txtTargetComplete]='" & _
Forms![frmactionseditc].[txtTargetComplete] & "'")
If chk = -1 Then
MsgBox "The box is " & chk & "!" & vbCrLf & " The Incident No is: " & inc,
vbOKOnly, "OK"
Me![txtTargetComplete].Locked = True
Me![txtTargetComplete].Enabled = False
Else
MsgBox "The box is " & chk & "!" & vbCrLf & "The Incident No is: " & inc,
vbOKOnly, "OK"
Me![txtTargetComplete].Enabled = True
Me![txtTargetComplete].Locked = False
End If
End Sub
What the HECK am I doing wrong!?