473,326 Members | 2,732 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

Stop while...wend statement on Unload Userform

Hi,

I have created a command button that validates information on the userform. For example:

While textbox1.Text = ""
MsgBox "Please enter the reference of the document.", vbExclamation, "Document Reference"
userform1.Hide
userform1.Show
Wend

And i have another command button to unload the userform.

Private Sub exit_Click()
Unload userform1
End Sub

but when i click it, it keeps executing the while of the validation botton. How can i stop that and just Unload the userform1.

Thanks.
Sep 10 '07 #1
3 2119
kadghar
1,295 Expert 1GB
change WHILE for IF
and WEND for END IF

Remember WHILE, FOR and DO will make loops until the code stop them.
IF will only make the comparision once
Sep 10 '07 #2
Robbie
180 100+
Hi,

but when i click it, it keeps executing the while of the validation botton. How can i stop that and just Unload the userform1.
- Add a variable at form-level which is a boolean type, called StopValidating
- Change the While line to include and StopValidating=False
- In the code for when unloading the form, set StopValidating to True. That way, the While condition will turn out FALSE and so the loop will break.

Hope it helps! =D
Sep 10 '07 #3
kadghar
1,295 Expert 1GB
- Add a variable at form-level which is a boolean type, called StopValidating
- Change the While line to include and StopValidating=False
- In the code for when unloading the form, set StopValidating to True. That way, the While condition will turn out FALSE and so the loop will break.

Hope it helps! =D
in that case dont forget to put DoEvents inside the loop
Sep 10 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: Baz | last post by:
Hi All, I have a problem with the above command. I have a file which is approximately 7000 lines long. I want to parse that file, extract any lines containing a certain string, and add that line...
2
by: brentster | last post by:
I am trying to write a stored procedure that utilizes something like a while in ASP. my select statement is like this. s = select distinct(employee_id) from employee_table rs.Open s while...
0
by: szymon_k | last post by:
Hi. How to set the userform as subform of some access form? What I need to do is to insert some userform into the form, so that it will be under the same conditions of resize, move and other...
3
by: gw.boswell | last post by:
I have created a userform with textboxes for data entry. I also have a command button that calls a second useform. A user enters certain information in the first useform but if he/she wants to do...
2
by: williamyeow | last post by:
Hi i am new to excel VB. can anyone tell me how to link userform to another userform? My concept for my program I have set up a userform with a couple of option. after the user has chose the...
2
by: eSolTec, Inc. 501(c)(3) | last post by:
Thank you in advance for any and all assistance. Is there a way to start, pause and resume a recurrsive search exactly where you left off, say in the registry programmatically? -- Michael Bragg,...
2
by: adiel_g | last post by:
I added a user control to a webform in Asp.net 2.0. I am also adding several other user controls to this webform. Now I am trying to find a way to stop the user controls from loading up when I...
3
sweetzhay
by: sweetzhay | last post by:
i already know how to get the output of 1 12 123 1234 12345 using while wend and now my problem is to show the output of 1 21
3
pod
by: pod | last post by:
Hello What I want to do is: from this workbook (thisWB), I want to access a userform's properties that are in another Workbook (toolWB) I can do this for worksheets, but I want to do it as...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.