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!

MsgBox appearing behind main form 2

Status
Not open for further replies.

GPM4663

Technical User
Aug 9, 2001
165
GB
Hi Everyone,
I have a main form and continuous subform with some check boxes on the subform. When the user ticks a check box I use the code below to display a msgbox if there is an issue. However the msgbox displays behind the main form and hence locks out the main form. The main form pop up is set to yes, modal set to no and the pop of the subform is set to no.

If I hit Ctl-alt-Delete the msgbox will then appear and I can clear it. I need the mainform popup property set to yes because I hide the access border on the interface. Can anyone help me out.

Many thanks in advance for any help,

GPM

Here is the code being used, RequestAll is the name of the check box:

Private Sub RequestAll_Click()

If Me.RequestAll = True Then
If Me.Availability <> "Made" Then
Me.RequestAll = False
Me.RequestedQty = ""
MsgBox ("This item will not be produced in time for the lorry!"), vbExclamation
Exit Sub
Else
Me.RequestAll = True
Me.RequestedQty = Me.Outstanding
End If
Else
Me.RequestedQty = ""
End If

Me.Refresh

End Sub

 
My first thought was that the msgbox should have a pop-up property to it, but then I remembered it's not actually your form.

I feel like I have seen this before, but not remembering the fix.

As a troubleshooting step, what if you edit your code to either

A) make the property of the main form pop-up = false and then make it true at the end, i.e. turn it off for the message and then back on

B) what happens if you turn modal to true and then run the event? does it still happen?

C) can you make the main form invisible when the event fires, so that the msg box is the only thing visible? then make it visible when the response is done?

Hopefully these ideas, while maybe not solutions, will help you discover what is happening. I just spent an entire day troubleshooting code and break pointing every line til I found the issue.

Sometimes turning settings on and off til you find the right combo is just the way to find the answer.

HTH

misscrf

It is never too late to become what you could have been ~ George Eliot
 
Hi MissCrf,
Thanks for your response, I have tried all those things but to no avail. The code won't let me set the popup property of the main form in runtime and changing the value of the subform to modal and then back again does not have any effect. Does it mean anything that everything works perfectly well when I step thru the process in the debugger?
This is really driving me mental so any other ideas would be a huge appreciation.

many thanks

GPM
 
One last ditch idea would be instead of letting access message box come up, have the checkbox click make your own form come up.

Create a form to look like a message box, and its response buttons contain the code for the potential responses. That form may have more ability to do what you want.

Just a thought.

misscrf

It is never too late to become what you could have been ~ George Eliot
 
How are ya GPM . . .

Actually the [blue]syntax is wrong![/blue] Typically in VBA you use parenthese when you want to use the returned value. This means all arguements go within the parenthese:
Code:
[blue]   [i]variable[/i] = MsgBox ("This item will not be produced in time for the lorry!", vbExclamation)[/blue]
If you don't intend to use the returned value from the function then drop parenthese:
Code:
[blue]  MsgBox "This item will not be produced in time for the lorry!", vbExclamation[/blue]

... perhaps this was the problem ...

See Ya! . . . . . .

Be sure to see thread181-473997 [blue]Worthy Reading![/blue] [thumbsup2]
Also faq181-2886 [blue]Worthy Reading![/blue] [thumbsup2]
 
See my plan was to keep trying to help until someone smart like aceman came along with the real solution! lol

misscrf

It is never too late to become what you could have been ~ George Eliot
 
Thank You misscrf . . .

Smart? . . . sometimes I wonder [thumbsup2]

See Ya! . . . . . .

Be sure to see thread181-473997 [blue]Worthy Reading![/blue] [thumbsup2]
Also faq181-2886 [blue]Worthy Reading![/blue] [thumbsup2]
 
As far as I'm concerned you are both incredibly smart!

Misscrf, loved your idea on creating my own msgbox to give me a lot more control over things....I think I might use that in some other places.

Aceman, I didn't realise that about the parenthese and when I tested it you were absolutely right! Got it working now!

Many thanks to you both, stars all round!

GPM
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top