Chinees - Simplificeren   Duits   Engels (Verenigde Staten)   Frans   Nederlands   Portugees - Iberisch   Spaans  

Home




Usenet Posting #15 - Trigeminal Software, Inc. (Dutch)


Onderwerp: INFO: De geformatteerde MsgBox in Access 2000
(Oorspronkelijk gepost 30 september 1999)
In Access 97 had de MsgBox-functie een gedocumenteerde syntax voor het aanmaken van geformatteerde berichtvensters door het gebruik van het @-teken. Het zou de Office-assistent gebruiken als deze aan stond. Je kon bijvoorbeeld het volgende gebruiken (uit de hulpfunctie van Access 97):

MsgBox "Verkeerde knop!@Deze knop werkt niet.@Probeer een andere.", _

   vbOKOnly + vbExclamation

In Access 2000 (die VBE, de Visual Basic Editor, heeft geintegreerd), roept de VBA-MsgBox-functie Access niet aan om dit uit te voeren, zodat de formattering verloren gaat en je ook de mogelijkheid verliest om de Office-assistent te gebruiken als "front" voor je boodschappen. Maar er is een oplossing!

Als je de Eval-functie gebruikt gaat je aanroep via de Expression Servie, die samenwerkt met Access en Jet om de MsgBox-functie uit te voeren, en het zal de Access-versie aanroepen in plaats van de VBA-versie. Je kunt de volgende functie toevoegen aan je Access-database en deze functie aanroepen in plaats van de VBA-MsgBox om de 97-functionaliteit te verkrijgen:

Function FormattedMsgBox( _
 Prompt As String, _
 Optional Buttons As VbMsgBoxStyle = vbOKOnly, _
 Optional Title As String = vbNullString, _
 Optional HelpFile As Variant, _
 Optional Context As Variant) _
 As VbMsgBoxResult
    If IsMissing(HelpFile) Or IsMissing(Context) Then
        FormattedMsgBox = Eval("MsgBox(""" & Prompt & _
         """, " & Buttons & ", """ & Title & """)")
    Else
        FormattedMsgBox = Eval("MsgBox(""" & Prompt & _
         """, " & Buttons & ", """ & Title & """, """ & _
         HelpFile & """, " & Context & ")")
    End If
End Function

Dit is het verschil. Je mag zelf beslissen welke je beter bevalt:

VBE MsgBox
           MsgBox "Wrong button!@This button doesn't work.@Try Another.", 
           vbOKOnly + vbExclamation, "My Application"
      
Formatted MsgBox
           FormattedMsgBox "Wrong button!@This button doesn't work.@Try Another.", 
           vbOKOnly + vbExclamation, "My Application"
      

Back to Usenet Musings


Problemen met deze pagina? Neem contact op met de webmaster@trigeminal.com
met uw commentaar, vragen of suggesties.