![]() |
![]() |
|
|||||||
| Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
New Member
Join Date: Apr 2002
Location: Contractors Steel Company
Posts: 6
|
I'm trying to write a userform with textboxes that, when the user gets to the end, loads its data into a worksheet, clears the userform, then starts over on the 1st field for a new record. I've got everything to work, except, after the user enters the last field on the userform, the form clears like it should, but it acts like bad data was entered on the 1st field and displays its error message. I setfocus to the field, but it doesn't stop there. Help!
|
|
|
|
|
|
#2 |
|
Board Regular
Join Date: Apr 2002
Location: Greenwood, SC
Posts: 677
|
Without seeing your form I cannot be sure, but it sounds like when you clear the data from the form, you are invoking whatever event you use to do your error handling.
I've had similar issues and handled it with a form-level public variable (I'll use a boolean as an example). When you load the form, set the boolean to false. Just before you clear the form, set the boolean to true. When you do the error checking, skip it if the boolean is true. When the focus goes to the first textbox (i.e. TextBox1_Enter), set the boolean back to false. If your problem was what I thought it was this (or something like it) should work. |
|
|
|
|
|
#3 |
|
New Member
Join Date: Apr 2002
Location: Contractors Steel Company
Posts: 6
|
I figured out the problem!!
Anytime you change the value of a textbox, you initiate an event (field change). It was triggering my "afterupdate" event. Solution: clear the field in the "enter" event. Problem solved. |
|
|
|
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|