Puzzle: Access Message Boxes with no VBA code (4 Viewers)

isladogs

Access MVP / VIP
Local time
Today, 15:13
Joined
Jan 14, 2017
Messages
19,496
Here is a small puzzle to help pass the time.
For Access 365 users, the attached database has 3 different styles of message box. In earlier versions, the last two messages have the same style

MsgBoxes.png


Each of the message boxes has been created without any VBA code.
The puzzle is simple and should hopefully only take a few minutes for experienced developers to work out. How are the different messages created?

Just for clarification, when I said this was done without any code, I didn't mean that AI had written the code for me. There is no VBA code anywhere in the database!

Article:

Video:
 

Attachments

It's cool. I can't say how it's done without trying to replicate it, and I don't claim I will be able to pull it off, but I did my checks and I can see some of the ingredients. There is VBA code to trigger the message boxes though.
 
No. There really is no VBA code as the video shows and you can check for yourself.
The messages are all created by the Access Expression Service. The question is how . . . and why each looks different to the others.
 
No. There really is no VBA code as the video shows and you can check for yourself.
The messages are all created by the Access Expression Service. The question is how . . . and why each looks different to the others.
There are snippets like =MsgBox("message" & Chr(10)...

We're gonna get into a different argument there, the syntax for message boxes is interchangeable, but I get your point. By the way, I've been away from the forum for a while, is this "message awaiting mod approval" guard new around here or it's just for this thread?
 
There is nothing to argue about. Everything I wrote here and in the article or said in the video is factually correct.
There are things I deliberately didn't say in order to make this into a puzzle.
But I will state that there is no trickery and it’s easy for anyone to do something like this. @tvanstiphout has already worked out how it was done.

There are at least 6 ways of creating message boxes.
For example, I could have used a macro to run the messages but I didn't do that either.
Indeed, doing that wouldn't allow me to create all three styles of message.

if you view the database in a text or hex editor you will indeed see MsgBox three times as there are three messages.
You will also see the words 'message box' and 'no code' several times as those are contained in each of the messages.

As for the other question, sample databases is a moderated area as is the code repository. That's always been the case.
 
Last edited:
you are using 4-5 arguments (parameters) of the msgbox (modern look) + the @ sign.
while on the normal msgbox, you only use 3.
 
Last edited:
That's how I get the different styles of message box using the Access expression service as my linked article explains in detail:


But how am I actually creating the message boxes without using VBA code?
 
Last edited:
i think the new msgbox coloring/bolding can only be done on form events directly "Expression" on the Event of the form.
like in the case of your Current Event and On Close event:
Code:
=Msgbox()

that way Access will Evaluate the expression, same as using Eval("Msgbox()")
you can't produce it using Msgbox on VBA.
 
Last edited:
With the two responses in posts 10 & 11 and also several direct messages from others, its time for me to explain fully how this works for those who aren't already aware. If you don't want to know the answer, please 'look away' now! 😁

Before I go any further, congratulations to @tvanstiphout, @arnelgp, @Lampje and @KitaYama - you worked out almost everything between you

The database has two hidden objects - an autoexec macro and a form.
It was also locked down with the navigation pane hidden and shift bypass disabled.

I could have done parts of this puzzle without a macro or without a form but I needed both for different features.
As stated repeatedly, there is no VBA code used in the app.

The autoexec macro is used to first open the form (hidden), then close it and finally quit the app.

1772457211869.png

Macro actions are XML and NOT VBA code (though they can be used to run VBA code or messages)

The hidden form is shown in @Lampje's screenshot in post #11 although he has modified the database slightly with additional objects.

The form runs three different styles of message in turn from the load, current & close events:. The message contents are entered directly into the property sheet. I could have used functions instead but that would require VBA code!

1772456460581.png


As mentioned there are at least 6 ways of running messages:
  • Using VBA code
  • from the Immediate window
  • as a function run from a form / report event in the property sheet
  • directly written into an event in the object property sheet
  • from a saved macro
  • from an embedded macro
The first 3 methods use the VBA MsgBox function, the last 3 use the Access Expression Service

I created messages from the property sheet as I needed to use the MsgBox function from the Access expression service.
This supports the Line1@Line2@Line3 notation. That is used to create the bold first line (message 2).
Alternatively, it creates the new style (message 3) if the help file and context arguments are included.
See my article: https://www.isladogs.co.uk/eval-new-style-msgbox/index.html

I could have created the first 2 messages direct from the macro but not the third as macros don't support the help file & context arguments

The VBA MsgBox function does not support this notation unless it is wrapped in the Eval function.
However, doing that causes the Access Expression Service to be used instead.

Whenever I try out unknown databases, I always run them from a non-trusted location to prevent code running.
However, even then, actions designated as 'safe' will still run from an autoexec macro.
So in this case, the first two messages still run but the third is blocked as it is immediately followed by an 'unsafe' action (marked with a warning sign in the macro)

1772457307414.png


The only thing nobody has yet explained is why the menu bar gets restricted only after you click OK on the second message.
Its not difficult to explain but I'll leave that as 'unsolved' for now.

NOTE: Now the puzzle is out of the way, I intend to write a short article about running messages using the Access Expression Service.

Attached is a fully unlocked version of the puzzle app
 

Attachments

Last edited:
If you place a function in the property sheet of a form or report event, then that is using VBA code.
Running a message using the Expression Service from a macro or directly from a form event is code of a different 'type' but it is not VBA code.
 
If you place a function in the property sheet of a form or report event, then that is using VBA code.
Running a message using the Expression Service from a macro or directly from a form event is code of a different 'type' but it is not VBA code.
A macro can handle an event and show the message box; It's not VBA but it's code.
 
@RonPaii
I've already explained the difference. There's little point both of us repeating the same points over and over . . .
 
@isladogs

isladogs: The only thing nobody has yet explained is why the menu bar gets restricted only after you click OK on the second message.

Lampje: The addition ;"";0) removes it.
 
@isladogs

isladogs: The only thing nobody has yet explained is why the menu bar gets restricted only after you click OK on the second message.

Lampje: The addition ;"";0) removes it.

Good guess but not correct. You can remove those two arguments from the final message and the ribbon menu changes just the same.
Obviously the message appearance then changes to a bold first line style
 
Last edited:
The only thing nobody has yet explained is why the menu bar gets restricted only after you click OK on the second message.
I had only 15 minutes break time to check what's you'e done.
Not sure if what I think is correct or not, but at least I tried.
Check your DM.
 
Last edited:

Users who are viewing this thread

Back
Top Bottom