Forms question

TheWennerWoman

Active Member
Joined
Aug 1, 2019
Messages
270
Office Version
  1. 365
Platform
  1. Windows
Hello, I have frm_Main_Menu containing several buttons. If one of them is pressed, a second form pops up asking for the user to enter a company code. When they click OK on that, the second form unloads and some code goes away to get data from a database. While this is happening, I'd like a form to pop up saying "data being retrieved, please wait" (ideally right after they clicked OK). When the data is returned I want the "data being retrieved" form to go away.

How can I achieve this?

I keep running into "error 402 - must close or hide topmost modal form first"?
 

Excel Facts

Add Bullets to Range
Select range. Press Ctrl+1. On Number tab, choose Custom. Type Alt+7 then space then @ sign (using 7 on numeric keypad)
This is Access or no? Reads like it is, but you posted in Excel forum. Post your code so someone has something to work with? Or in the event that closes said form add code to open the message form first, then do whatever to get the data. When that is done, control will pass back to this procedure whereupon you can close the message form.
 
Upvote 0
This is Access or no? Reads like it is, but you posted in Excel forum. Post your code so someone has something to work with? Or in the event that closes said form add code to open the message form first, then do whatever to get the data. When that is done, control will pass back to this procedure whereupon you can close the message form.
It's Excel.

Code:
Private Sub CommandButton1_Click()
Range("co_chosen").Value = Me.cmb_Company_Code.Value
frm_wait.Show
Call getrecords
frm_wait.Hide
Unload Me
frm_Tabbed.Show
End Sub

frm_wait.Show appears fine ("please wait, data is being retrieved") but it doesn't get beyond frm_wait.hide....the forms just sits there and if I red x it to close that's when I get the "error 402 - must close or hide topmost modal form first"
 
Upvote 0
You could use a multipage on your second form (you can hide the tabs) and on the second page just have a label with the "please wait..." text on it. When you click the button, switch to the second page, then hide the form when the retrieval is over (a form shouldn't really unload itself - whatever called it should take care of that).
 
Upvote 0
Solution
but it doesn't get beyond frm_wait.hide
If Excel is a single thread process like Access then it's because control passes to the process that gets the data. In the meantime you can't do much in the code, if anything, until control passes back to your code. If you just wait for the data retrieval process to complete, your next line of code should execute. Does that not happen?
 
Upvote 0

Forum statistics

Threads
1,214,927
Messages
6,122,311
Members
449,080
Latest member
jmsotelo

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top