For...Next statement woes

  • Thread starter John S. Ford, MD
  • Start date
J

John S. Ford, MD

Can someone tell me what the problem is with this code?

Dim ctl as Control
For Each ctl In Me.Controls
If (TypeOf ctl Is ComboBox Or TypeOf ctl Is TextBox) And
(ctl.Name <> txtTeamName) Then
ctl.Locked = False
End If
Next ctl

The program seems to ignore the (ctl.Name <> txtTeamName) clause and
improperly UNlocks txtTeamName.

Any idea what I'm doing wrong?

John
 
M

M.L. Sco Scofield

You need to quote the name you are looking for. Try:

.... (ctl.Name <> "txtTeamName"),,,

The default property of a test box is the Value property. Without the
quotes, you were comparing ctl.Name with the current contents of
txtTeamName.

Good luck.

Sco
 
M

M.L. Sco Scofield

You're welcome.

--

Sco

M.L. "Sco" Scofield, Microsoft Access MVP, MCSD, MCP, MSS, A+
Useful Metric Conversion #17 of 19: 1 billion billion picolos = 1 gigolo
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

Top