PDA

View Full Version : Concentrating string variable with form or control name



inso18
02-26-2007, 07:57 AM
Hello, I've just joined, good to be here.

I have a quick question: How is it possible to concentrate a string var. with form or control name? I would like to be able to find a specific subform control and assign it as a form variable:


Dim strSubformName As String
Dim frm1, frm2 As Form
Dim ctl, ctl2 As Control
Set frm1 = Me.Customers
For Each ctl1 In frm1.Controls
If Left(ctl1.Name, 3) <> "cmd" Then
'find subforms only
strSubformName = ctl.name
Set frm2 = Forms!Customers!&strSubformName 'doesn't work
'change something in subform
For Each ctl2 in frm2.Controls
ctl2.Top = ctl2.Top + 20
Next ctl2
Set frm = Nothing
End If
Next ctl1


Thanks very much for your attention,
Michael

Sjefke
03-06-2007, 03:46 PM
Set frm2 = Forms!Customers!Controls(strSubformName)

A Subform is a control as such (like a button, textbox etc.) on the mainform - it is part of the Controls-collection.

mdmackillop
03-06-2007, 04:35 PM
...is it possible to concentrate a string var I think the term you're meaning is Concatenate.

You might also use numbers as in


For i = 1 to 5
Set frm2 = Forms!Customers!Controls("textbox" & i)
DoEvents
Next