Share via

Modifying control.layout using VBA using Access >= 2007

Anonymous
2010-07-20T13:25:30+00:00

Hi,

I'm developping an application wher a form creates another form. So I use CreateControl to add controls in this new form.

I wan't to use the stacked layout feature, but the control.layout (as the control.layoutID) property is read-only.

    Set ctl = CreateControl(frm.Name, acLabel, acDetail, parent, , 100, currentTop, 10000, 500)

    With ctl

        .Name = "Label_" & num

        .Caption = label

        '.Layout = acLayoutStacked ' This throws an error about read-only property

        .Properties!Layout = acLayoutStacked ' This does nothing

    end with

How am I supposed to switch my controls to stacked layout ?

Note that with layout == 0, RowStart, RowEnd, ColumnStart and ColumnEnd properties do not exist, so I can't just set them.

Thanks !

Microsoft 365 and Office | Access | For home | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

6 answers

Sort by: Most helpful
  1. Anonymous
    2010-07-20T15:11:04+00:00

    I once used a browser control on a Access Form. Built up a form in html load it into the control and trapped the events to read through and update records. Rendering HTML forms is very flexible. I think you trap the BeforeNavigate2 event to gather the data after the form is submitted and read the form values through the DOMDocument model..


    Trevor Lowing, PMP http://officetechsupport.wordpress.com/

    Was this answer helpful?

    0 comments No comments
  2. Anonymous
    2010-07-20T14:57:22+00:00

    Thank you, but I need an unknown number of controls in the form : the number of controls depends on the number of rows in a table.

    Continuous form will not do it either, as I need different controls types for each row in my table.

    Was this answer helpful?

    0 comments No comments
  3. Anonymous
    2010-07-20T14:23:24+00:00

    In almost all situations, using CreateForm and/or CreateControl (or any persistent design change) in a running application is a really bad practice.  A form/report is a heavy duty object that will bloat the front end db and that will require more frequent Compact operations, which in turn requires a robust backup procedure.  It will also greatly increase the chance of corruption and will not work at all in an MDE or AccDE file.

    A way better approch is to use a predefinied form and use code in the Open event to make nonpersistent changes to the form's and its controls' properties.  This approach typically is easier and requires less code than creating a form from scratch.

    Was this answer helpful?

    0 comments No comments
  4. Anonymous
    2010-07-20T13:55:11+00:00

    Helpful, thanks, but throws error 2046 (not yet available).

    (of course my form is open in design mode, I call createForm just before).

    If this is the way to do it, then I'm stuck.

    Thanks anyway.

    Was this answer helpful?

    0 comments No comments
  5. Tom van Stiphout 40,211 Reputation points MVP Volunteer Moderator
    2010-07-20T13:45:22+00:00

    Try this: runcommand acCmdStackedLayout

    Your form is open in design view, right?

    -Tom.

    Microsoft Access MVP


    -Tom. Microsoft Access MVP

    Was this answer helpful?

    0 comments No comments