Using a variable to refer to a control in VBA

  • Thread starter Thread starter Dale K
  • Start date Start date
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
 
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...)
 
Back
Top