Display results of an SQL query in a MsgBox

Alterras

New member
Local time
Today, 14:38
Joined
Aug 24, 2020
Messages
1
Hey there folks, I'm a bit new to this whole thing, and i'm working on training for a project at work. The Project leader wants us to be able to display the result of an SQL query in a Message Box, but i keep getting mixed up and lost in things. If anyone could offer a suggestion or the like, i would be super appreciative.

Thanks.
 
Best solution to me seems to be a model form in tabular format, which is made to look like a message box... but that is my 2 cents
 
Like @namliam said. Make a pop up form with a subform. Set the subform sourceobject to the query. Make it so that it is locked, no additions, no deletions. Use open args to pass in any message you would want to pass in. I would then make a generic function so you can call this from anywhere and pass in the sourceobject name and the message you want.
 
Hi. Welcome to AWF!

If you must use a message box, look into using an ADO recordset. It has GetRows and GetString methods.
 
Last edited:
A project leader who insists on using a message box for this simply doesn't have a clue about Access. A form that does not allow edits is a better solution.
 
What do you mean when you say SQL result? If the result contains only one data, you can assign the result of this query to a text box on the form. You can also show the value of this Textbox with MsgBox message. However, if you will show results in a list, you can design a separate form instead of MsgBox and add a text box (long text) to this form and display it.
 
If the SQL query results in a fairly limited number of rows, it's no problem to display in a message box. But you should be aware that message boxes will only display so much text on screen. If there is any chance that what you are going to display will exceed that, you might as well just make a form for display purposes as others have mentioned.
Odds are your project manager won't know nor care the difference.
 

Users who are viewing this thread

Back
Top Bottom