PC Review


Reply
Thread Tools Rate Thread

ADO Recordset to Msgbox

 
 
=?Utf-8?B?UGF1bCBGYXVsa25lcg==?=
Guest
Posts: n/a
 
      12th Sep 2007
How do I take the contents of a ADO recordset and show them in a messagebox.

thanks for any help
Paul
 
Reply With Quote
 
 
 
 
Bob Phillips
Guest
Posts: n/a
 
      12th Sep 2007
' 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" <(E-Mail Removed)> wrote in message
news:95AA1929-3736-4742-B063-(E-Mail Removed)...
> How do I take the contents of a ADO recordset and show them in a
> messagebox.
>
> thanks for any help
> Paul



 
Reply With Quote
 
=?Utf-8?B?UGF1bCBGYXVsa25lcg==?=
Guest
Posts: n/a
 
      12th Sep 2007
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" <(E-Mail Removed)> wrote in message
> news:95AA1929-3736-4742-B063-(E-Mail Removed)...
> > How do I take the contents of a ADO recordset and show them in a
> > messagebox.
> >
> > thanks for any help
> > Paul

>
>
>

 
Reply With Quote
 
RB Smissaert
Guest
Posts: n/a
 
      12th Sep 2007
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" <(E-Mail Removed)> wrote in message
news:A36D3D7B-86FD-475F-A210-(E-Mail Removed)...
> 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" <(E-Mail Removed)> wrote in message
>> news:95AA1929-3736-4742-B063-(E-Mail Removed)...
>> > How do I take the contents of a ADO recordset and show them in a
>> > messagebox.
>> >
>> > thanks for any help
>> > Paul

>>
>>
>>


 
Reply With Quote
 
=?Utf-8?B?UGF1bCBGYXVsa25lcg==?=
Guest
Posts: n/a
 
      12th Sep 2007
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" <(E-Mail Removed)> wrote in message
> news:A36D3D7B-86FD-475F-A210-(E-Mail Removed)...
> > 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" <(E-Mail Removed)> wrote in message
> >> news:95AA1929-3736-4742-B063-(E-Mail Removed)...
> >> > How do I take the contents of a ADO recordset and show them in a
> >> > messagebox.
> >> >
> >> > thanks for any help
> >> > Paul
> >>
> >>
> >>

>
>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
MsgBox - Display variable in MsgBox Shiller Microsoft Access VBA Modules 2 29th Sep 2008 10:14 PM
Substituting my own MsgBox for the standard delete confirm MsgBox John S. Ford, MD Microsoft Access Getting Started 8 20th Aug 2004 12:05 AM
Substituting my own MsgBox for the standard delete confirm MsgBox John S. Ford, MD Microsoft Access Forms 8 20th Aug 2004 12:05 AM
Substituting my own MsgBox for the standard delete confirm MsgBox John S. Ford, MD Microsoft Access 8 20th Aug 2004 12:05 AM
Substituting my own MsgBox for the standard delete confirm MsgBox John S. Ford, MD Microsoft Access Form Coding 8 20th Aug 2004 12:05 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 05:37 AM.