For...Next statement woes

  • Thread starter Thread starter John S. Ford, MD
  • Start date 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
 
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
 
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
 
Back
Top