isladogs
Access MVP / VIP
- Local time
- Today, 02:14
- Joined
- Jan 14, 2017
- Messages
- 19,391
OK as nobody else has responded, I asked CoPilot to do so. Its answer was explicitly based on this thread even though I didn't mention it! Judge for yourself whether its giving additional info or is just referencing/reinforcing earlier responses.
Remember that CoPilot like all LLMs likes to please.
Q:
Forum question: What exactly does Eval("MsgBox()") do when the HelpFile and Context arguments are omitted?
A:
It’s a great question, and the thread you’re reading gives the clues but never quite spells out the underlying mechanism. The short version is:
When you call:
Access does not call the built‑in VBA
Instead, Access routes the call through the Access expression service, which has its own internal implementation of
That internal implementation behaves differently depending on whether the HelpFile and Context arguments are supplied.
produces the old style message box, even on Access 365 where the built‑in VBA
Access switches to the new-style message box renderer — the same one used by the modern VBA
This is the behaviour Colin and AHeyne confirmed in the thread access-programmers.co.uk.
Because the Access expression service (the engine behind
It’s not documented anywhere by Microsoft, but the behaviour is consistent:
This is why FormattedMsgBox, which wraps
Because the expression service predates the new Fluent UI message box.
The old implementation was never removed — it’s simply triggered when the call signature matches the older version of the function.
So
If you want, I can also break down:
------------------------------------------------
For info, I did ask CoPilot the answer to the second bullet point.
Its response was interesting but I want to check the response before I post it in case its full of errors
Remember that CoPilot like all LLMs likes to please.
Q:
Forum question: What exactly does Eval("MsgBox()") do when the HelpFile and Context arguments are omitted?
A:
It’s a great question, and the thread you’re reading gives the clues but never quite spells out the underlying mechanism. The short version is:
What Eval("MsgBox()") actually does when HelpFile and Context are omitted
When you call:
Code:
Eval("MsgBox(""Hello"")")
MsgBox function directly.Instead, Access routes the call through the Access expression service, which has its own internal implementation of
MsgBox.That internal implementation behaves differently depending on whether the HelpFile and Context arguments are supplied.
1. When HelpFile and Context are omitted
Access uses the legacy (old‑style) message box renderer — the one with:- Bold first line
- Classic Windows 7–style layout
- No theme support
- No coloured default button
- No oversized title text
Code:
Eval("MsgBox(""Hello"")")
MsgBox now shows the new Fluent UI style.2. When HelpFile and Context are included
Even if they are empty strings or zero:
Code:
Eval("MsgBox(""Hello"", 64, ""Title"", """", 0)")
MsgBox in Access 365.This is the behaviour Colin and AHeyne confirmed in the thread access-programmers.co.uk.
Why does this happen?
Because the Access expression service (the engine behind Eval) contains two different internal message box implementations, and the presence of the last two arguments is the switch that determines which one is used.It’s not documented anywhere by Microsoft, but the behaviour is consistent:
| Arguments passed to Eval | Result |
|---|---|
Prompt, Buttons, Title only | Old-style message box |
Prompt, Buttons, Title, HelpFile, Context | New-style message box |
Eval, can produce both styles depending on whether you include those last two parameters.
Why does Access behave this way?
Because the expression service predates the new Fluent UI message box.The old implementation was never removed — it’s simply triggered when the call signature matches the older version of the function.
So
Eval("MsgBox()") is effectively calling:- Old internal MsgBox when only the first 1–3 arguments are present
- New internal MsgBox when all 5 arguments are present
If you want, I can also break down:
- How
Evalresolves function names - Why
Evalcan call functions that VBA cannot - How FormattedMsgBox uses this behaviour to override the built‑in MsgBox
- Why this behaviour is unique to Access and not Excel/Word
------------------------------------------------
For info, I did ask CoPilot the answer to the second bullet point.
Its response was interesting but I want to check the response before I post it in case its full of errors
Last edited: