David R
02-07-2002, 10:12 AM
I'm not sure if I've outsmarted myself or what. I want the control holding my index field to be locked to prevent accidental changes to existing records, but allow a double-click to unlock it. However it always stays locked, except yesterday it was always staying unlocked...??
Here's the relavant code snippets:
Private Sub Form_Current()
'Interfaces with ParticipantID_Lookup_AfterUpdate() to clear the lookup box and where to set the cursor
If (Me.ParticipantID_Lookup = "") Then 'No lookup, just browsing records
Me.ParticipantID_Lookup.SetFocus
Exit Sub
Else
If Me.NewRecord = False Then
'Old record, don 't want to change the ParticipantID unwittingly
Me.ParticipantID.Enabled = False
Me.ParticipantID.Locked = True
'^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^This was working, now it doesn't for new records.
Me.FirstName.SetFocus
Else
'New record, import the data stored in Me.ParticipantID_Lookup
Me.ParticipantID.Enabled = True
Me.ParticipantID.Locked = False
'^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^This was working, now it doesn't for new records.
'If (Me.ParticipantID_Lookup = "") Then Me.ParticipantID = Me.ParticipantID_Lookup
Me.ParticipantID.SetFocus
End If
Me.ParticipantID_Lookup = ""
End If
End Sub
Private Sub ParticipantID_GotFocus()
Me.ActiveControl.SelStart = 0
End Sub
Private Sub ParticipantID_BeforeUpdate(Cancel As Integer)
If (Me.NewRecord = False) Then
If (Me.ParticipantID = "" Or IsNull(Me.ParticipantID) = True) Then Me.Undo
End If
If DCount("[ParticipantID]", "tableParticipants", "[ParticipantID]= '" & Me![ParticipantID] & "'") = 1 Then
MsgBox "This is a duplicate Participant ID."
Me.Undo
Cancel = True
End If
End Sub
Private Sub ParticipantID_DblClick(Cancel As Integer)
Me.ParticipantID.Enabled = True
Me.ParticipantID.Locked = False
End Sub
Any ideas peripheral to this are as always appreciated.
David R
Here's the relavant code snippets:
Private Sub Form_Current()
'Interfaces with ParticipantID_Lookup_AfterUpdate() to clear the lookup box and where to set the cursor
If (Me.ParticipantID_Lookup = "") Then 'No lookup, just browsing records
Me.ParticipantID_Lookup.SetFocus
Exit Sub
Else
If Me.NewRecord = False Then
'Old record, don 't want to change the ParticipantID unwittingly
Me.ParticipantID.Enabled = False
Me.ParticipantID.Locked = True
'^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^This was working, now it doesn't for new records.
Me.FirstName.SetFocus
Else
'New record, import the data stored in Me.ParticipantID_Lookup
Me.ParticipantID.Enabled = True
Me.ParticipantID.Locked = False
'^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^This was working, now it doesn't for new records.
'If (Me.ParticipantID_Lookup = "") Then Me.ParticipantID = Me.ParticipantID_Lookup
Me.ParticipantID.SetFocus
End If
Me.ParticipantID_Lookup = ""
End If
End Sub
Private Sub ParticipantID_GotFocus()
Me.ActiveControl.SelStart = 0
End Sub
Private Sub ParticipantID_BeforeUpdate(Cancel As Integer)
If (Me.NewRecord = False) Then
If (Me.ParticipantID = "" Or IsNull(Me.ParticipantID) = True) Then Me.Undo
End If
If DCount("[ParticipantID]", "tableParticipants", "[ParticipantID]= '" & Me![ParticipantID] & "'") = 1 Then
MsgBox "This is a duplicate Participant ID."
Me.Undo
Cancel = True
End If
End Sub
Private Sub ParticipantID_DblClick(Cancel As Integer)
Me.ParticipantID.Enabled = True
Me.ParticipantID.Locked = False
End Sub
Any ideas peripheral to this are as always appreciated.
David R