By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
429,116 Members | 1,509 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 429,116 IT Pros & Developers. It's quick & easy.

How to loop through controls in form?

P: n/a
Very basic question:

Should I use Me.Controls or Me.Form.Controls when looping through controls
like this:

Private Sub LockControls(blnLock As Boolean)
Dim varCtl As Variant
Me!cboData.SetFocus
Me!cmdStop.Visible = blnLock

For Each varCtl In Array("cboData", "txtOutput", "chkOpen",
"cboChartColors")
Me.Form.Controls(varCtl).Locked = blnLock
Next

For Each varCtl In Array("cmdBrowseData", "cmdBrowseOutput", _
"cmdCreateExcel", "cmdStatusLog", "cmdClearPaths", _
"cmdOpenOutputFile", "cmdAdvancedSettings")
Me.Form.Controls(varCtl).Enabled = IIf(blnLock, False, True)
Next

End Sub

Thanks in advance.
Nov 13 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Me.Controls

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)

"deko" <de**@deko.com> wrote in message
news:4s*****************@newssvr21.news.prodigy.co m...
Very basic question:

Should I use Me.Controls or Me.Form.Controls when looping through controls
like this:

Private Sub LockControls(blnLock As Boolean)
Dim varCtl As Variant
Me!cboData.SetFocus
Me!cmdStop.Visible = blnLock

For Each varCtl In Array("cboData", "txtOutput", "chkOpen",
"cboChartColors")
Me.Form.Controls(varCtl).Locked = blnLock
Next

For Each varCtl In Array("cmdBrowseData", "cmdBrowseOutput", _
"cmdCreateExcel", "cmdStatusLog", "cmdClearPaths", _
"cmdOpenOutputFile", "cmdAdvancedSettings")
Me.Form.Controls(varCtl).Enabled = IIf(blnLock, False, True)
Next

End Sub

Thanks in advance.

Nov 13 '05 #2

P: n/a
The "Me" notation means the current form/report and is a shortcut that
replaces "Forms!myFormName". So, "Me.Form" doesn't really mean anything.
-Ed

"deko" <de**@deko.com> wrote in message
news:4s*****************@newssvr21.news.prodigy.co m...
Very basic question:

Should I use Me.Controls or Me.Form.Controls when looping through controls
like this:

Private Sub LockControls(blnLock As Boolean)
Dim varCtl As Variant
Me!cboData.SetFocus
Me!cmdStop.Visible = blnLock

For Each varCtl In Array("cboData", "txtOutput", "chkOpen",
"cboChartColors")
Me.Form.Controls(varCtl).Locked = blnLock
Next

For Each varCtl In Array("cmdBrowseData", "cmdBrowseOutput", _
"cmdCreateExcel", "cmdStatusLog", "cmdClearPaths", _
"cmdOpenOutputFile", "cmdAdvancedSettings")
Me.Form.Controls(varCtl).Enabled = IIf(blnLock, False, True)
Next

End Sub

Thanks in advance.

Nov 13 '05 #3

P: n/a
> The "Me" notation means the current form/report and is a shortcut that
replaces "Forms!myFormName". So, "Me.Form" doesn't really mean anything.


10-4. They both worked - now I understand why.
Nov 13 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.