Assigning "TopMargin", got Error.

  • Thread starter Thread starter mkhmer
  • Start date Start date
M

mkhmer

Hi, Can anybody help me on this error?

All the time I try to assing the "TopMargin" property to a control at
runtime, it always return error:
========
"Object doesn't support this property or method You entered an expression
that has an invalid reference to the property topmargin"
========

My code is:
========
For each Ctl in MyForm.Controls
Ctl.Setfocus
Ctl.Properties("TopMarging")=0.05 'this line return error
Ctl.Properties("FontName")="Tahoma" 'this line work
Next
========

Your help is appreciated.

Thanks,
MKHMER
 
(1) You spelled it TopMargin>>>g<<<, and

(2) Access controls do not have that property!

You might mean Top. See Top, Left, Width & Height in F1 help.

HTH,
TC (MVP Access)
http://tc2.atspace.com
 
MKHMER ,

Textboxes and labels are the only form controls that have a TopMargin
property. The form's Control collection contains all controls. If you have
anything but textboxes and labels on your form, that's where the error is
coming from. Also, labels do not have a SetFocus method and that line of
code will throw an error.

Try:

For Each ctl In MyForm.Controls
If ctl.ControlType = acLabel Or ctl.ControlType = acTextBox Then
ctl.TopMargin = 0.05
ctl.FontName = "Tahoma"
End If
Next

For more information, take a look at the code sample in help for the
ControlType property.

Good luck.

Sco

M.L. "Sco" Scofield, MCSD, MCP, MSS, A+, ex-MVP
Denver Area Access Users Group 2006 President www.DAAUG.org
MS Colorado Events Administrator www.MSColoradoEvents.com
Useful Metric Conversion #19 of 19: 2 wharves = 1 paradox
Miscellaneous Access and VB "stuff" at www.ScoBiz.com
 
Hello Grasshopper, er, Master Jeff.

Good to see you.

Sco

M.L. "Sco" Scofield, MCSD, MCP, MSS, A+, ex-MVP
Denver Area Access Users Group 2006 President www.DAAUG.org
MS Colorado Events Administrator www.MSColoradoEvents.com
Useful Metric Conversion #19 of 19: 2 wharves = 1 paradox
Miscellaneous Access and VB "stuff" at www.ScoBiz.com
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top