PC Review


Reply
Thread Tools Rate Thread

ADODB Recordset

 
 
crosley4@gmail.com
Guest
Posts: n/a
 
      29th Oct 2008
This function worked in Access 2003, but does not in 2007, can anyone
please tell me why not. The ADODB .Recordset declaration and the .
Active Connection parameter don't seem to work for starters.

What I am doing is scroll through a recordset, "CurrentGradStudents
table" and storing the values for display on a report into a variable
"strHold" then formating the value in a field called "cltDest".
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

Public Function LookUpAbsentias()
Dim rst As ADODB.Recordset
Set rst = New ADODB.Recordset
Dim strHold As Variant
Dim ctlDest As Controls
Dim cltDest As Variant

With rst

Set .ActiveConnection = CurrentProject.Connection
.CursorType = adOpenKeyset
.Open "LookUpAbsentias", Options:=adCmdTableDirect
If .RecordCount > 0 Then
.MoveFirst
Do Until .EOF
strHold = strHold & "" & .Fields("Name") & " ("
& .Fields("Term") & ") " & ", "
.MoveNext
Loop
End If

cltDest = "Absentia:" & vbCrLf & strHold & vbCrLf & vbCrLf & _
"* F=Fall Only; S=Spring Only; Y=Fall and Spring "
'MsgBox cltDest
Reports![FieldList2Report]![Absentias].Caption = cltDest
.Close


End With

Set rst = Nothing

End Function

>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

 
Reply With Quote
 
 
 
 
Tom van Stiphout
Guest
Posts: n/a
 
      29th Oct 2008
On Wed, 29 Oct 2008 06:50:27 -0700 (PDT), (E-Mail Removed) wrote:

Make sure you set a reference to the ADO library. Code window > Tools
> References


-Tom.
Microsoft Access MVP


>This function worked in Access 2003, but does not in 2007, can anyone
>please tell me why not. The ADODB .Recordset declaration and the .
>Active Connection parameter don't seem to work for starters.
>
>What I am doing is scroll through a recordset, "CurrentGradStudents
>table" and storing the values for display on a report into a variable
>"strHold" then formating the value in a field called "cltDest".
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

>Public Function LookUpAbsentias()
>Dim rst As ADODB.Recordset
>Set rst = New ADODB.Recordset
>Dim strHold As Variant
>Dim ctlDest As Controls
>Dim cltDest As Variant
>
>With rst
>
> Set .ActiveConnection = CurrentProject.Connection
> .CursorType = adOpenKeyset
> .Open "LookUpAbsentias", Options:=adCmdTableDirect
> If .RecordCount > 0 Then
> .MoveFirst
> Do Until .EOF
> strHold = strHold & "" & .Fields("Name") & " ("
>& .Fields("Term") & ") " & ", "
> .MoveNext
> Loop
> End If
>
> cltDest = "Absentia:" & vbCrLf & strHold & vbCrLf & vbCrLf & _
> "* F=Fall Only; S=Spring Only; Y=Fall and Spring "
> 'MsgBox cltDest
>Reports![FieldList2Report]![Absentias].Caption = cltDest
> .Close
>
>
> End With
>
> Set rst = Nothing
>
>End Function
>
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

 
Reply With Quote
 
crosley4@gmail.com
Guest
Posts: n/a
 
      29th Oct 2008
On Oct 29, 10:07*am, Tom van Stiphout <tom7744.no.s...@cox.net> wrote:
> On Wed, 29 Oct 2008 06:50:27 -0700 (PDT), crosl...@gmail.com wrote:
>
> Make sure you set a reference to the ADO library. Code window > Tools
>
> > References

>
> -Tom.
> Microsoft Access MVP
>
>
>
> >This function worked in Access 2003, but does not in 2007, can anyone
> >please tell me why not. The ADODB .Recordset declaration and the .
> >Active Connection parameter don't seem to work for starters.

>
> >What I am doing is scroll through a recordset, "CurrentGradStudents
> >table" *and storing the values for display on a report into a variable
> >"strHold" then formating the value in a field called "cltDest".

>
> >Public Function LookUpAbsentias()
> >Dim rst *As ADODB.Recordset
> >Set rst = New ADODB.Recordset
> >Dim strHold As Variant
> >Dim ctlDest As Controls
> >Dim cltDest As Variant

>
> >With rst

>
> > * *Set .ActiveConnection = CurrentProject.Connection
> > * *.CursorType = adOpenKeyset
> > * *.Open "LookUpAbsentias", Options:=adCmdTableDirect
> > * *If .RecordCount > 0 Then
> > * * *.MoveFirst
> > * * *Do Until .EOF
> > * * * *strHold = strHold & "" & .Fields("Name") & " ("
> >& .Fields("Term") & ") " & ", "
> > * * * *.MoveNext
> > * * * * * * Loop
> > * * * * End If

>
> > *cltDest = "Absentia:" & vbCrLf & strHold & vbCrLf & vbCrLf & _
> > *"* F=Fall Only; *S=Spring Only; Y=Fall and Spring *"
> > * * * *'MsgBox cltDest
> >Reports![FieldList2Report]![Absentias].Caption = cltDest
> > * * * * * * .Close

>
> > * *End With

>
> > * *Set rst = Nothing

>
> >End Function- Hide quoted text -

>
> - Show quoted text -


Thanks again.. I referenced the Miscrosoft ActiveX data object library
2.1 and the code now works....
 
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
Cannot add form.recordset to adodb.recordset =?Utf-8?B?VG9yZQ==?= Microsoft Access ADP SQL Server 10 1st Jun 2007 10:50 PM
Access 2002: bind adodb recordset to listbox recordset property Craig Buchanan Microsoft Access Form Coding 2 1st May 2005 12:14 AM
Problem with Set combobox.recordset = <adodb.recordset> Gijs Beukenoot Microsoft Access Form Coding 0 10th Nov 2004 06:22 PM
Equivalent ADODB.Connector and ADODB.Recordset in VB.NET Marty Microsoft Dot NET 3 25th Sep 2004 10:36 PM
Equivalent ADODB.Connector and ADODB.Recordset in VB.NET Marty Microsoft VB .NET 3 25th Sep 2004 10:36 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 03:06 AM.