By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,397 Members | 1,425 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,397 IT Pros & Developers. It's quick & easy.

HOw may I hide a MSGBOX in access form using MSGBOX command

100+
P: 222
Hello everybody :)


is there any function in Visual basic that I can use it to have a message box for my form for a certain second and after it will hide automatically


for example :

"""SAVE IS IN PROGRESS PLEASE WAIT"""
I need that guys because I use a while command to navigate every record in my subform and when user click on the keyboard or on the mouse I'm having an error I was thinking to freez the form for a while ... any method or suggesion about this subject pleaseeeeeeeeeeeeeeeeeee help meeeeeeeeeee
Aug 6 '07 #1
Share this Question
Share on Google+
14 Replies


Rabbit
Expert Mod 10K+
P: 12,396
You use a modal form instead of a message box.
Aug 6 '07 #2

100+
P: 222
What can modal do for me ... I'm using this command to alwyas have the focus on the form until user close it ....

How may this command help me to have a text box until my while loop end ...?
Aug 6 '07 #3

missinglinq
Expert 2.5K+
P: 3,532
You need to give us more information on exactly what it is you're trying to Accomplish. For instance, why are you navigating every record in your subform?

Welcome to TheScripts!

Linq ;0)>
Aug 6 '07 #4

100+
P: 222
I navigate every record because after the new data will be in inserted on the subform user need to change them all by on click


SO

I made a bottom in the form so when the user click on the bottom I got the focus on the subform and I navigate all record related to the record on the form

THE PROBLEM IS : while the computer is using the WHILE command and the user click on the mouse or on the keyboard he will have undefined error ( send and don't send )

What I'm trying to find is to post a message box to freez this form while the processor is on the while command and after he end the while the message box will Disappear


SORRY but I'm trying to find an IDEA more than a command cz I'm not sure even of my IDEA ...any method or comment please write it for meeeeee

THANK YOU
Aug 6 '07 #5

Rabbit
Expert Mod 10K+
P: 12,396
I still don't understand what it is you're trying to do while the form is locked down but a MsgBox halts execution until it returns. There's no way for you to have it up and have code run and then get rid of it.

Opening a modal form will prevent the user from activating any other object but still allow execution of code. You can close the form afterwards.

I highly doubt however, that you need to step through each record of your subform to accomplish what you want to do. If we had a better idea of what you're trying to do you could probably bypass the whole process altogether.
Aug 6 '07 #6

FishVal
Expert 2.5K+
P: 2,653
Hi gentlemen.

I'd like to introduce you somewhat unusual way to close MsgBox via setting Win Timer.

in a form module:
Expand|Select|Wrap|Line Numbers
  1. Option Compare Database
  2. Dim lngTimerID As Long
  3.  
  4. Private Sub btnTemporayMsgBox_Click()
  5.  
  6.     'set 1000 ms system timer and open MsgBox
  7.     lngTimerID = SetTimer(Me.hWnd, 0, 1000, AddressOf TimerProc)
  8.     MsgBox "Hello, world!"  'silly joke, I know :)
  9.  
  10. End Sub
  11.  
in a public module:
Expand|Select|Wrap|Line Numbers
  1. Option Compare Database
  2.  
  3. Public Declare Function SetTimer Lib "user32" _
  4.      (ByVal hWnd As Long, ByVal uTimerID As Long, ByVal uInterval As Long, _
  5.      ByVal fpCallback As Long) As Long
  6.  
  7. Public Declare Function KillTimer Lib "user32" _
  8.     (ByVal hWnd As Long, ByVal uTimerID As Long) As Boolean
  9.  
  10. Public Sub TimerProc(ByVal hWnd As Long, ByVal uMsg As Long, _
  11.     ByVal uEvent As Long, ByVal dwTime As Long)
  12.  
  13.     'send Alt-F4 combination to active window, this must be modal MsgBox
  14.     SendKeys "%{F4}"
  15.     'kill timer or otherwise it will close everything down to Access itself
  16.     KillTimer hWnd, uEvent
  17.  
  18. End Sub
  19.  
  20.  
Aug 6 '07 #7

Rabbit
Expert Mod 10K+
P: 12,396
Will this allow code to run while the MsgBox is up? And can you make it close only after the rest of the code has run?
Aug 6 '07 #8

100+
P: 222
No rabbits isn't working ... the program don't enter into while command unless the msgbox will exit :( :( :(


I need them in parallel :( ...
Aug 7 '07 #9

P: 47
Maybe this is a little more complicated than I think but I think the following would do what you require:

1. Create a Global Boolean , e.g bFormReady
2. Set this to FALSE when you start your subform processing
3. Set it to TRUE when subform processing complete
4. Include the following code in your messagebox form

<code>
Sub Form_Load()
While not bFormReady
DoEvents
Wend
Docmd.Close acform, Me.Name
End Sub
</code>
Aug 7 '07 #10

FishVal
Expert 2.5K+
P: 2,653
Hello everybody :)


is there any function in Visual basic that I can use it to have a message box for my form for a certain second and after it will hide automatically


for example :

"""SAVE IS IN PROGRESS PLEASE WAIT"""
I need that guys because I use a while command to navigate every record in my subform and when user click on the keyboard or on the mouse I'm having an error I was thinking to freez the form for a while ... any method or suggesion about this subject pleaseeeeeeeeeeeeeeeeeee help meeeeeeeeeee
Hi, there.

Posting the entire code will help the community to understand what do you actually mean. Your explanation so far does not make much sence, for me at least. It seems that you are trying to do a simple thing in a very bizzare and unnatural way.

P.S. Plz, don't mention my previously posted code. It is not a solution of your problem and, I think will not even point you in a right direction. It simply a tricky and, to tell the truth, somewhat unreliable way to kill MsgBox.
Aug 7 '07 #11

100+
P: 222
That is my code :

Having a form "invoices" and subform"Invoiceoutdetail Subform"

' what i need is to have a MSGBOX alert here


While ([Invoiceoutdetail Subform].[Form]![Barecodedetail] <> 0)
[Invoiceoutdetail Subform].[Form]![quantityout].SetFocus
Dim a, b, c, d, e, x, sumb As Double
a = [Invoiceoutdetail Subform].[Form]![quantityout]
b = [Invoiceoutdetail Subform].[Form]![SellerPricedetail]
c = [Invoiceoutdetail Subform].[Form]![Discdetail]
d = [Invoiceoutdetail Subform].[Form]![OriginalPricePro]
e = Me.Disc
If ([Invoiceoutdetail Subform].[Form]![lowestpricepro] > b - (c + e) * b * 0.01) Then
[Invoiceoutdetail Subform].[Form]![lowestpricepro] = b - (c + e) * b * 0.01
End If
[Invoiceoutdetail Subform].[Form]![ftotal] = a * b - (a * b * (c + e) * 0.01)
x = (a * b - (c) * a * b * 0.01) - (a * b - (c) * a * b * 0.01) * e * 0.01 - d * a
sumb = sumb + x
[Invoiceoutdetail Subform].[Form]![benefit] = x
[Invoiceoutdetail Subform].[Form]![CustomerID] = Me.CustomerID
[Invoiceoutdetail Subform].[Form]![ftotal] = (a * b - a * b * c * 0.01) - (a * b - a * b * c * 0.01) * Me.Disc * 0.01
DoCmd.GoToRecord , , acNext
Wend

' here is the end of the msgbox

the goal is to stop user to interrupt the while because SOMETIMES I'm getting an error ....
Aug 7 '07 #12

Scott Price
Expert 100+
P: 1,384
A
That is my code :

Having a form "invoices" and subform"Invoiceoutdetail Subform"

' what i need is to have a MSGBOX alert here


While ([Invoiceoutdetail Subform].[Form]![Barecodedetail] <> 0)
[Invoiceoutdetail Subform].[Form]![quantityout].SetFocus
Dim a, b, c, d, e, x, sumb As Double
a = [Invoiceoutdetail Subform].[Form]![quantityout]
b = [Invoiceoutdetail Subform].[Form]![SellerPricedetail]
c = [Invoiceoutdetail Subform].[Form]![Discdetail]
d = [Invoiceoutdetail Subform].[Form]![OriginalPricePro]
e = Me.Disc
If ([Invoiceoutdetail Subform].[Form]![lowestpricepro] > b - (c + e) * b * 0.01) Then
[Invoiceoutdetail Subform].[Form]![lowestpricepro] = b - (c + e) * b * 0.01
End If
[Invoiceoutdetail Subform].[Form]![ftotal] = a * b - (a * b * (c + e) * 0.01)
x = (a * b - (c) * a * b * 0.01) - (a * b - (c) * a * b * 0.01) * e * 0.01 - d * a
sumb = sumb + x
[Invoiceoutdetail Subform].[Form]![benefit] = x
[Invoiceoutdetail Subform].[Form]![CustomerID] = Me.CustomerID
[Invoiceoutdetail Subform].[Form]![ftotal] = (a * b - a * b * c * 0.01) - (a * b - a * b * c * 0.01) * Me.Disc * 0.01
DoCmd.GoToRecord , , acNext
Wend

' here is the end of the msgbox

the goal is to stop user to interrupt the while because SOMETIMES I'm getting an error ....
Does it HAVE to be a message box, or can you use an hourglass, with added code to make visible a label on the form telling the user to wait until processing is done before doing anything else?

To make this really 'foolproof', you could, for example, size an invisible label to fit exactly over your form... In font 24 or larger bold and red "DO NOT MOVE UNTIL DONE PROCESSING!!!". Make this visible thus covering your entire (modal) form, until the 'while' code is done executing. If you want added security, select all the controls on the form and set their properties to locked in the same section of code. The hourglass just gives a nice visually pleasing touch to the whole scenario...

Regards,
Scott
Aug 7 '07 #13

100+
P: 222
Yes That is what I'm trying to do: Hide a label that has a caption "Save is in progress ..."

Anyway thank you all for all your comments :) :)
Aug 8 '07 #14

Scott Price
Expert 100+
P: 1,384
Yes That is what I'm trying to do: Hide a label that has a caption "Save is in progress ..."

Anyway thank you all for all your comments :) :)
Hiding the label is as simple as setting it's visible property to false when you create it.

In VBA you can then set it to true in the lines of code before your while statement. Something like this: label1.Visible = True
After your code executes, return it to false. The hourglass command is part of the DoCmd group. It also accepts True and False to turn it on and off.

Regards,
Scott
Aug 8 '07 #15

Post your reply

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