Display Record in MsgBox (Excel VBA)

nataliek92

New Member
Joined
Oct 29, 2014
Messages
40
Hi Everyone

Hoping this is a simple question - any help would be appreciated!

I would like to display a record in a message box but can't seem to find anything online to help me do this.

I am using MS VBA for Excel 2010. I would like a MsgBox to display the single result from this SQL string :

Code:
str1 = "SELECT CAST(MIN(LoginDate) AS DATE) FROM AgentLoginTable"

Currently, I have a full working code which extracts data and places it into a cell in my workbook. I know I could easily use this code then reference that cell in a MsgBox, but I'm quite fussy and like my reports to be nice and clean! Basically I would like a MsgBox to pop up containing the record. It's just for reference, so the user can see the value. Hopefully someone can help.... This is my working string which places the record into cell A1 on "MyPage".

Code:
     With rs1
            .ActiveConnection = cnn1
            .Open str1
            Worksheets("MyPage").Range("A1").CopyFromRecordset rs1
            .Close
    End With

In theory, I would like a code such as
Code:
MsgBox.CopyfromRecordset rs1
but obviously this won't work.

Any advice?

Thank you in advance.
 

Excel Facts

Create a Pivot Table on a Map
If your data has zip codes, postal codes, or city names, select the data and use Insert, 3D Map. (Found to right of chart icons).

Forum statistics

Threads
1,223,247
Messages
6,171,007
Members
452,374
Latest member
keccles

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top