Msgbox bovenaan in Access 2010

Status
Niet open voor verdere reacties.

Michel1955

Gebruiker
Lid geworden
28 feb 2014
Berichten
57
Hi,
Is het mogelijk in Access 2010 VBA om een MSGBOX the laten verschijnen boven alle open windows.
De VBA module wordt opgestart vanuit Outlook 2010 en blijft steeds verdoken steken.
Tx
 
Waarschijnlijk is Outlook nog de actieve applicatie omdat je de msgbox vanuit een Outlook procedure opstart. Hoe ziet je code er uit? Want zonder code is er maar weinig van te zeggen verder.
 
Vba

In Outlook :

Sub Check_test()
Dim LPath As String
Dim LCategoryID As Long
Dim oapp As Object
LPath = path\DB_BE.accdb"
Set oapp = CreateObject("Access.Application")
On Error Resume Next
oapp.Visible = False
On Error Resume Next
oapp.OpenCurrentDatabase LPath, False
oapp.Run "check"
Set oapp = Nothing
End Sub

In Access :

Public Sub check()
Dim strsql As String
Dim db As DAO.Database, rs As DAO.Recordset
Dim DayB As Date, DayL As Date, datum As Date
Dim strmsg As String
DayB = FirstDayInMonth
DayL = LastDayInMonth

strsql = "SELECT datum, Sum(1) AS Aantal FROM tabel "
strsql = strsql & "GROUP BY datum, code "
strsql = strsql & "HAVING datum >= " & Chr(35) & DayB & Chr(35) & " and "
strsql = strsql & "datum < " & Chr(35) & DayL & Chr(35) & " and "
strsql = strsql & "code = 1 ;"
Set db = CurrentDb()
Set rs = db.OpenRecordset(strsql, dbOpenDynaset)
With rs
If .RecordCount = 0 Then
MsgBox "Er zijn voor de periode " & DayB & " - " & DayL & " geen records beschikbaar.", vbInformation
GoTo einde
Else
.MoveLast
If .RecordCount > 1 Then
.MoveFirst
strmsg = ""
Do Until .EOF
If !aantal > 1 Then
strmsg = strmsg & "Er zijn voor " & ! datum & ", " & !aantal & " records beschikbaar." & vbCrLf
Else
strmsg = strmsg & "Er zijn voor " & ! datum & ", " & !aantal & " record beschikbaar." & vbCrLf
End If
.MoveNext
Loop
MsgBox strmsg, vbInformation
Else
If !aantal > 1 Then
MsgBox "Er zijn voor " & ! datum & ", " & !aantal & " records beschikbaar.", vbInformation
Else
MsgBox "Er zijn voor " & ! datum & ", " & !aantal & " record beschikbaar.", vbInformation
End If
End If
GoTo einde
End If
End With
einde:
rs.Close
db.Close
Set rs = Nothing
Set db = Nothing
End Sub

Public Function FirstDayInMonth(Optional iDate As Variant) As Date
If IsMissing(iDate) Then
iDate = Date
End If
FirstDayInMonth = DateSerial(Year(iDate), Month(iDate), 1)
End Function

Public Function LastDayInMonth(Optional iDate As Variant) As Date
If IsMissing(iDate) Then
iDate = Date
End If
LastDayInMonth = DateSerial(Year(iDate), Month(iDate) + 1, 0)
End Function
 
Doe ons een lol en maak bovenstaande code op met de CODE toets; dit soort lange lappen leest niet lekker...
 
Maar wat ik wel zie: als je een object invisible opent, dan gaat het natuurlijk nooit goed. Probeer dit eens:
Code:
    Set oApp = CreateObject("Access.Application")
    With oApp
        .OpenCurrentDatabase LPath, False
        .Visible = True
        .Activate
        .WindowState = wdWindowStateMaximize
    End With
 
Status
Niet open voor verdere reacties.
Steun Ons

Nieuwste berichten

Terug
Bovenaan Onderaan