MsgBox OnOpen Event

damian

Registered User.
Local time
Today, 21:13
Joined
Jun 27, 2004
Messages
87
I have some code in the open event of a form that opens a msgbox but the msgbox takes focus and has to be acknowledged before the form appears.

I would like the form to appear first and then for the msgbox to automatically open. Is this possible?
 
Use the form timer to open the MsgBox.
 
Last edited:
Thanks Allan, will give it a go.
 
If you key in EVENTS into the Access Help system (not VBA Help) it lists all of the events and the sequence. The Open event is way too early in the sequence to do what you were doing.
 
Steps to take

Goto form properties

Set
Timer Interval to 100
Timer Event [Event Procedure]

Form Timer Event
Me.TimerInterval = 0 To ensure it only runs one
MsgBox ....

When the form opens one tenth of a second later the msgbox appears.

David
 
Thanks very much David - works a treat.

On a slightly different note, wonder if you could also assist with following as you've already assisted and you appear to be the DLookup king. The following code was working until I included a letter in the unbound txtBarcode value (wanted to add letter and for code to open a form based upon value of this letter - this will come later) I then want to remove the letter from the end, convert the remaining value to 'long' and use it to open the form where it's equal to the signin ID value. Getting a data mismatch criteria error but I'm scratching my head for correct syntax - I've seen it recently in other posts but I've been struggling to find over past few hours. Any ideas (see the Clarets are off to a great start!)

Private Sub txtBarcode_AfterUpdate()
Dim strCriteria As String
Dim Cancel As Boolean
Dim rs As Object
Dim valueSignInID As Integer
Dim lngNumericalID As Long

'take letter off end
lngNumericalID = CLng(Left(Me.txtBarcode, Len(Me.txtBarcode) - 1))

strCriteria = "[signinID] =" & "'" & lngNumericalID & "'"

valueSignInID = Nz(DLookup("signinid", "ContractorSignOUTDetailsQuery", "[signinID] =" & "'" & strNumericalID & "'"))
If Nz(valueSignInID, 0) = 0 Then
Me.txtBarcode.SetFocus
Else
DoCmd.OpenForm "ContractorSignoutDetailsForm", , , strCriteria

Me.txtBarcode.Undo
DoCmd.Close acForm, Me.Name
End If
Set rs = Nothing
End Sub
 
Remove the quotes around the numbers. When using code, quotes need to be placed around strings...but with numbers you dont use them.
 
Thanks - it works!!! State of disbelief here as I removed the quotes earlier in an attempt to guess syntax but it failed to work. Must have removed the pertinent info on this occasion.

Thanks again
 

Users who are viewing this thread

Back
Top Bottom