My control won't lock in the OnCurrent event

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I am using the code below in the OncCUrrent event of a form so that as a user
navigates through records, he or she cannot make changes to "Closed" items.
It does not, however, seem to work. Any help?

If (cbostatus = "Closed") Then
cbostatus.Locked = True
chkPositive.Locked = True
chkCritical.Locked = True
ElseIf (cbostatus = "Open") Then
cbostatus.Locked = False
chkPositive.Locked = False
chkCritical.Locked = False
End If
 
The code looks OK.
What field is cboStatus "bound" to? (Let's say it's a field in the table
called [Status])
What are the columns in cboStatus? (In order... left to right)
What is your Bound Column property set to?

I think that perhaps the combo is displaying "Open" or "Closed", but what's
really stored in the [Status] field is the value of one of the other
cboStatus columns. So... cboStatus (and it's bound field [Status]) is never
equal to either "Open" or "Closed"

hth
Al Camp
 
Thanks for your help Al. cbostatus is a bound combobox, but it is bound to a
1 col value list with just three options: "Open", "Closed, "Maintenance". So
far as I can tell, the value of the combobox really is Closed then.

AlCamp said:
The code looks OK.
What field is cboStatus "bound" to? (Let's say it's a field in the table
called [Status])
What are the columns in cboStatus? (In order... left to right)
What is your Bound Column property set to?

I think that perhaps the combo is displaying "Open" or "Closed", but what's
really stored in the [Status] field is the value of one of the other
cboStatus columns. So... cboStatus (and it's bound field [Status]) is never
equal to either "Open" or "Closed"

hth
Al Camp

bjnova said:
I am using the code below in the OncCUrrent event of a form so that as a
user
navigates through records, he or she cannot make changes to "Closed"
items.
It does not, however, seem to work. Any help?

If (cbostatus = "Closed") Then
cbostatus.Locked = True
chkPositive.Locked = True
chkCritical.Locked = True
ElseIf (cbostatus = "Open") Then
cbostatus.Locked = False
chkPositive.Locked = False
chkCritical.Locked = False
End If
 
I don't know if this helps, but the locking on chkPositive and chkCritical
both work fine.

AlCamp said:
The code looks OK.
What field is cboStatus "bound" to? (Let's say it's a field in the table
called [Status])
What are the columns in cboStatus? (In order... left to right)
What is your Bound Column property set to?

I think that perhaps the combo is displaying "Open" or "Closed", but what's
really stored in the [Status] field is the value of one of the other
cboStatus columns. So... cboStatus (and it's bound field [Status]) is never
equal to either "Open" or "Closed"

hth
Al Camp

bjnova said:
I am using the code below in the OncCUrrent event of a form so that as a
user
navigates through records, he or she cannot make changes to "Closed"
items.
It does not, however, seem to work. Any help?

If (cbostatus = "Closed") Then
cbostatus.Locked = True
chkPositive.Locked = True
chkCritical.Locked = True
ElseIf (cbostatus = "Open") Then
cbostatus.Locked = False
chkPositive.Locked = False
chkCritical.Locked = False
End If
 
The behavior on the OnCurrent event is very squirrelly: sometimes cbostatus
is locking and sometimes it's not. So, I've changed my approach, and it
seems to be working fine: if the condition is met (so, cbostatus="Closed") I
set the form's AllowEdits property to False.
 
Back
Top