PDA

View Full Version : Placing msgbox in foreground



Waubain
06-30-2010, 12:02 PM
I use a button on a slide in PP that calls up an Access database, randomly chooses a student, and places that student name in a Msgbox. My problem is that in Slide Show (PP 2007) the Msgbox sits behind the slide not in the foreground as in the past. It works fine in the VBA window. Any advice is appreciated.

PP Slide Button VBA:

Private Sub cmdchoose_Click()
Call HideTaskbar
Const cDatabaseToOpen = "E:\pullname.mdb"
On Error Resume Next
Dim AcApp As Object
Set AcApp = CreateObject("Access.Application")
Application.ShowWindowsInTaskbar = msoFalse
If Val(AcApp.Version) >= 12 Then ' original was 11
AcApp.AutomationSecurity = 1 ' msoAutomationSecurityLow
End If
AcApp.Application.Visible = False
AcApp.OpenCurrentDatabase cDatabaseToOpen
If AcApp.CurrentProject.FullName <> "" Then
AcApp.UserControl = True
Else
AcApp.Application.Quit 'origially AcApp.Quit
MsgBox "Failed to open '" & cDatabaseToOpen & "'."
End If
AcApp.DoCmd.RunMacro "autoexec"
Call UnhideTaskbar
End Sub

Access Form VBA:

Option Compare Database
Option Explicit
Private Sub cmdrandomstudent_Click()
Dim db As Database
Dim rst As Recordset
Set db = CurrentDb
Set rst = db.OpenRecordset("tblstudents")
rst.Index = "id"
Randomize
rst.Seek "=", Int((DCount("*", "tblstudents") - 1 + 1) * Rnd + 1)
If rst.NoMatch = False Then
MsgBox "" & rst!studentname
End If
End Sub
Private Sub cmdclose_Click()
On Error GoTo Err_cmdclose_Click
DoCmd.Close
Exit_cmdclose_Click:
Exit Sub
Err_cmdclose_Click:
MsgBox Err.Description
Resume Exit_cmdclose_Click

End Sub
Private Sub Form_Load()
End Sub
Private Sub Form_Open(Cancel As Integer)
Dim db As Database
Dim rst As Recordset
Set db = CurrentDb
Set rst = db.OpenRecordset("tblstudents")
rst.Index = "id"
Randomize
rst.Seek "=", Int((DCount("*", "tblstudents") - 1 + 1) * Rnd + 1)
If rst.NoMatch = False Then
MsgBox "" & rst!studentname
End If
Application.Quit
End Sub