Form Current event error

Dan25e

Registered User.
Local time
Today, 15:21
Joined
Dec 3, 2014
Messages
33
Hi folks,

I have error 438 Object doesn't support property or method in a Form On Current event.

Error trapping is turned on, reason being I converted the form to accde and it stopped working!

The code is...


Private Sub Form_Current()
On Error Resume Next
Dim ctl As Control

'Me.CC_Spare_3.Enabled = False

For Each ctl In Me.Controls
'If CC Complete is NOT "Completed" and it is Checked, Lock all other
'Controls. If it is not checked Unlock them

If ctl.Name <> "Check411" Then
ctl.Locked = Me![Check411] 'Evaluates to True/False
End If

Next

End Sub

The highlighted text when in debugger is

ctl.Locked = Me![Check411]

Any ideas?

Thanks in adavance
 
will this help:

ctl.Locked = Nz(Me![Check411],False)

or

ctl.Locked = Me("Check411")

or

ctl.Locked = Nz(Me("Check411"), False)
 
In many cases it is worthwhile to think about what the error message says. It here says you are attempting to do something to an object that cannot be done. So evidently some object you are looping through does not have a .Locked proprty

BTW:

On Error Resume Next

is not error trapping. With a few exception it is just a silly short-term band-aid for lazy prgrammers.

Download the free mz-tools to get an easy way to add error handling to many subs/functions in one go
 
Thanks spikepl.

I turned on the error trapping in the tools menu of the VBA window which is what made this show up. Turning off the error trapping and putting a ' before the On Error Resume Next did exactly the same thing!

Every day is a school day!
 
Turns out to be something to do with the first record in the table. I nulled the value and the error stopped showing up. Subsequent records do what they're supposed to.

Anyone know why this is so?
 

Users who are viewing this thread

Back
Top Bottom