Access VBADiscuss using VBA for Access programming.
Welcome to the p2p.wrox.com Forums.
You are currently viewing the Access VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
I am building a list of check boxes on an Access form programatically. But when I try to assign a caption to each checkbox, I get the error "Object doesn't support this property or method". The error occurs on the line where I try to set the caption property. I have also tried ".Text" with the same result. I am using Access 2003. Any help would be greatly appreciated.
Here is my code:
With myCheckBox
.Name = "cb" & i
.Caption = "cb" & i ' error occurs on this line
.Left = 100
.Top = 100 + (i * 300)
.Height = 200
.Width = 200
End With
This could look like a stupid question, but are you trying to do this on the check box itself or on the label of the check box?
Cause if you are trying to do this on the check box itself, I don't think it can work cause you do not have a 'caption' property... On the label it should work cause there you have it...
Not a stupid question. I'm guessing that I need to create a checkbox AND a label separately based on your response. If this is the case, I suppose I have my answer. If not, please advise.
Vince is correct. The caption is a property of a label. You should not have to create a checkbox AND a label because when you create a checkbox, an associated label should appear with it.
Greg Serrano
Michigan Dept. of Environmental Quality, Air Quality Division