Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem with On Change event

Status
Not open for further replies.

emumaster

Programmer
Aug 30, 2001
31
US
I have code that has been working fine in access 2002, but in access 2003 it just freaks out by staying in an endless loop.

the code is in the On Change event for a textbox.
Here's the code:

Private Sub txtCityName_Change()
Dim db as dao.database
Dim rs as dao.recorset
dim strsql as string
Dim vCity as string
Dim vNameLen As Integer

If gClear = True then
Me.txtCityName.Text = ""
Exit Sub
End if


What happens is after I hit enter in the text box, it hits the change event and goes down into the subroutine, because gClear(a global variable) has been set to true. After it hits the Exit Sub It goes right back up to the top(Private Sub txtCityName_Change()) and starts over. It just keeps doing this endlessly. Like I said earlier. This works fine in Access 2002 but not in 2003.

Any help would be appreciated.



 
Yes, assigning something to the .Text property of a control, may set off events which is normally only fired by users stuffing the control manually - try assigning to the .value property in stead (or drop the property all together, since the value property is default) - but surely, this is more appropriate in the forms forum (forum702?) - and, mind your typo in the recorset declaration ...

Roy-Vidar
 
Sorry about posting in the incorrect forum.
I wasn't sure, since it involved access vba code.

Assigning to the .value property cleared up the problem.

Thanks again!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top