Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default ADO Recordset to Msgbox

How do I take the contents of a ADO recordset and show them in a messagebox.

thanks for any help
Paul
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,593
Default ADO Recordset to Msgbox

' Check to make sure we received data.
If Not oRS.EOF Then
ary = oRS.getrows
MsgBox ary(0, 0) & " " & ary(1, 0) & ", " & ary(2, 0)
Else
MsgBox "No records returned.", vbCritical
End If



--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)

"Paul Faulkner" wrote in message
...
How do I take the contents of a ADO recordset and show them in a
messagebox.

thanks for any help
Paul



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default ADO Recordset to Msgbox

Thanks Bob,
But having trouble with this as I never know how many records could
potentially be returned in the recordset so I can't define the line

MsgBox ary(0, 0) & " " & ary(1, 0) & ", " & ary(2, 0)

yet my attempts to cycle through the array are failing miserably, so far
looking like this

If Not rs.EOF Then
Ary = rs.GetRows
For varX = LBound(Ary) To UBound(Ary)
strMsg = strMsg & Ary(varX, 0) & ", "
Next varX
strMsg = Mid(strMsg, 1, Len(strMsg) - 2)
MsgBox (strMsg)
Else
MsgBox "No records returned.", vbCritical
End If

But this isn't going through the array and working either!

Paul

"Bob Phillips" wrote:

' Check to make sure we received data.
If Not oRS.EOF Then
ary = oRS.getrows
MsgBox ary(0, 0) & " " & ary(1, 0) & ", " & ary(2, 0)
Else
MsgBox "No records returned.", vbCritical
End If



--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)

"Paul Faulkner" wrote in message
...
How do I take the contents of a ADO recordset and show them in a
messagebox.

thanks for any help
Paul




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,452
Default ADO Recordset to Msgbox

Try this:

Sub test()

Dim i As Long
Dim Ary
Dim strMsg As String

If Not rs.EOF Then
Ary = rs.GetRows
For i = 0 To UBound(Ary, 2)
If i = 0 Then
strMsg = Ary(0, i)
Else
strMsg = strMsg & ", " & Ary(0, i)
End If
Next i
MsgBox strMsg, , UBound(Ary, 2) + 1 & " records"
Else
MsgBox "No records returned.", vbCritical
End If

End Sub


The essential thing is that the array obtained from rs.GetRows has the
dimensions oppposite to what you would expect.


RBS


"Paul Faulkner" wrote in message
...
Thanks Bob,
But having trouble with this as I never know how many records could
potentially be returned in the recordset so I can't define the line

MsgBox ary(0, 0) & " " & ary(1, 0) & ", " & ary(2, 0)

yet my attempts to cycle through the array are failing miserably, so far
looking like this

If Not rs.EOF Then
Ary = rs.GetRows
For varX = LBound(Ary) To UBound(Ary)
strMsg = strMsg & Ary(varX, 0) & ", "
Next varX
strMsg = Mid(strMsg, 1, Len(strMsg) - 2)
MsgBox (strMsg)
Else
MsgBox "No records returned.", vbCritical
End If

But this isn't going through the array and working either!

Paul

"Bob Phillips" wrote:

' Check to make sure we received data.
If Not oRS.EOF Then
ary = oRS.getrows
MsgBox ary(0, 0) & " " & ary(1, 0) & ", " & ary(2, 0)
Else
MsgBox "No records returned.", vbCritical
End If



--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my
addy)

"Paul Faulkner" wrote in message
...
How do I take the contents of a ADO recordset and show them in a
messagebox.

thanks for any help
Paul





  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default ADO Recordset to Msgbox

Thank you, that works perfectly

cheers,
Paul

"RB Smissaert" wrote:

Try this:

Sub test()

Dim i As Long
Dim Ary
Dim strMsg As String

If Not rs.EOF Then
Ary = rs.GetRows
For i = 0 To UBound(Ary, 2)
If i = 0 Then
strMsg = Ary(0, i)
Else
strMsg = strMsg & ", " & Ary(0, i)
End If
Next i
MsgBox strMsg, , UBound(Ary, 2) + 1 & " records"
Else
MsgBox "No records returned.", vbCritical
End If

End Sub


The essential thing is that the array obtained from rs.GetRows has the
dimensions oppposite to what you would expect.


RBS


"Paul Faulkner" wrote in message
...
Thanks Bob,
But having trouble with this as I never know how many records could
potentially be returned in the recordset so I can't define the line

MsgBox ary(0, 0) & " " & ary(1, 0) & ", " & ary(2, 0)

yet my attempts to cycle through the array are failing miserably, so far
looking like this

If Not rs.EOF Then
Ary = rs.GetRows
For varX = LBound(Ary) To UBound(Ary)
strMsg = strMsg & Ary(varX, 0) & ", "
Next varX
strMsg = Mid(strMsg, 1, Len(strMsg) - 2)
MsgBox (strMsg)
Else
MsgBox "No records returned.", vbCritical
End If

But this isn't going through the array and working either!

Paul

"Bob Phillips" wrote:

' Check to make sure we received data.
If Not oRS.EOF Then
ary = oRS.getrows
MsgBox ary(0, 0) & " " & ary(1, 0) & ", " & ary(2, 0)
Else
MsgBox "No records returned.", vbCritical
End If



--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my
addy)

"Paul Faulkner" wrote in message
...
How do I take the contents of a ADO recordset and show them in a
messagebox.

thanks for any help
Paul





Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
ADO recordset Kirk P. Excel Programming 2 April 6th 07 07:22 PM
Need ADO Recordset Help Mr B[_2_] Excel Programming 9 April 21st 06 04:51 PM
Using DSUM on a Recordset Chaplain Doug Excel Programming 1 January 10th 06 11:46 PM
Type recordset/recordset? FlaviusFlav[_9_] Excel Programming 4 May 24th 04 12:16 PM
Recordset Stephan Kassanke Excel Programming 0 September 10th 03 04:45 PM


All times are GMT +1. The time now is 03:29 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"