Programatically creating multiple checkboxes

sdang4657 used Ask the Experts™
I want to read some records from a table and then create a checkbox for each of the records with a label containing the record content.  Does anyone know how this can be done?  Thanks!
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®


I should have mentioned that this is being done in MS Access

What part do you need help with?

Maybe this will help:


while not rstADO.EOF
  intNextCheckBox = ubound(chkRecord) + 1
  Load chkRecord(intNextCheckBox)
  with chkRecord(intNextCheckBox)
    .Move chkRecord(intNextCheckBox-1).Top + .Height
    .Caption = rstADO.Fields(0).Value
    .Visible = True
  end with


...oh, in Access?  The above is for VB with an Access connection...
Ensure you’re charging the right price for your IT

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden using our free interactive tool and use it to determine the right price for your IT services. Start calculating Now!

Add a checkbox to your form and set the index property to 0. the following code shows how to add more at runtime.

Private Sub Check1_Click(Index As Integer)
    debug.Print index
End Sub

Private Sub Form_Load()
    Load Check1(1)
    Check1(1).Top = 500
    Check1(1).Left = 500
    Check1(1).Visible = True
    Load Check1(2)
    Check1(2).Top = 1000
    Check1(2).Left = 500
    Check1(2).Visible = True
End Sub

hello, status? comments? Feedback?
Author of the Year 2009

Hi sdang4657,
It appears that you have forgotten this question. I will ask Community Support to close it unless you finalize it within 7 days. I will ask a Community Support Moderator to:

    Accept mccainz2's comment(s) as an answer.

sdang4657, if you think your question was not answered at all or if you need help, just post a new comment here; Community Support will help you.  DO NOT accept THIS comment as an answer.
DanRollins -- EE database cleanup volunteer
Per recommendation.

EE Moderator

I should have piped up before...user asked to "read some records from a table" then make checkbox labels with info from DB.  Mine offered that.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial