WannaKatana
WannaKatana

Reputation: 5

Access VBA control reference issue?

I'm trying to loop through all the controls on an Access form but for some reason the controls object is not giving me the correct properties. When I select and right click on "Control" (in 'As Control') it says "identifier under cursor is not recognized".

I'm thinking it's a reference issue but I can't figure what's missing or incorrect. I don't get any syntax error so Control is a valid object.

I tried decompiling, repair and compacting just to be sure.

enter image description here

enter image description here

Upvotes: 0

Views: 212

Answers (1)

Andre
Andre

Reputation: 27644

The generic control object doesn't have too many useful properties or methods.

It covers also things like lines or subform containers or tab cards, which don't have much in common.

The specific controls like Textboxes have all the properties you are probably looking for.

You still can loop over all controls, and set the usual properties that most controls have, like .Visible or .Locked. Even if Intellisense doesn't provide them.

ctl.Locked = bLocked will work.

But you should handle (On Error Goto) or ignore (On Error Resume Next) runtime errors that will occur, if one control doesn't have the property you want to set.


Bonus question to everyone: why does the generic control object have the .Dropdown method that applies only to combo boxes? Very strange.

Upvotes: 1

Related Questions