Using a variable to refer to a control in VBA

D

Dale K

Good Afternoon,

I was wondering if any one can tell me how to fix the 3rd line to work like
the 2nd one does. The 2nd one works fine but one the 3rd one they system
throws an error.

thanks!

Dale

Dim intloop as integer
intloop=8
Forms![frmDate]![frmsubMonth].Form![subForm8].visible = False
Forms![frmDate]![frmsubMonth].Form!("subFrom" & intloop & "").visible = False
 
J

John W. Vinson

Good Afternoon,

I was wondering if any one can tell me how to fix the 3rd line to work like
the 2nd one does. The 2nd one works fine but one the 3rd one they system
throws an error.

thanks!

Dale

Dim intloop as integer
intloop=8
Forms![frmDate]![frmsubMonth].Form![subForm8].visible = False
Forms![frmDate]![frmsubMonth].Form!("subFrom" & intloop & "").visible = False

Assuming that frmSubMonth is a Subform control, and that somewhere on that
control is a sub-subform named subForm8, try

Forms![frmDate]![frmsubMonth].Form.Controls("subForm" & intloop).visible =
False

I presume that subFrom for subForm was a typo (having made that typo many
times myself...)
 

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

Top