Solved

View Recordset

Posted on 2012-04-06
9
493 Views
Last Modified: 2012-04-09
Is there a way to view a recordset without having to dump the data into a table and view the table?

Here is the code for the recordset

    Dim rst As ADODB.Recordset
    Dim strSql As String
    Dim strList As String
       
    Set cnn = CurrentProject.Connection
               
        strSql = "SELECT Number, PrimaryKey, ServCat, QualDesc, SeqID, AndOr, RevFrom,    RevTo, ProcFrom, ProcTo, POSFrom, POSTo, RiskComp, " _
        & "Div, Sequence, Column, CreationDate, ModificationDate, Status, Comment " _
        & "FROM tblServCatData " _
        & "WHERE ServCat = '" & txtServCatView & "'"
                         
    Set rst = New ADODB.Recordset
    rst.Open strSql, cnn, adOpenStatic, adLockOptimistic, adCmdText
           
    If rst.EOF = True Then
        MsgBox "No Records Found"
        Exit Sub
    End If
   
    'view recordset here by some function'

         
    set rst = Nothing
                         
End sub
0
Comment
Question by:ScootterP
  • 4
  • 4
9 Comments
 
LVL 22

Expert Comment

by:Kelvin Sparks
Comment Utility
What version of Access?

For the later ones, I believe you can set the recordsource of a form or report to a recordset.

By using continuous forms, you may be able to do this.

Have alook at

http://www.experts-exchange.com/Microsoft/Development/MS_Access/Access_Forms/Q_23958304.html

Kelvin
0
 

Author Comment

by:ScootterP
Comment Utility
Access 2003
I went to the link and tried to copy the code, it looks like it should work but I got an error.

Compile Error:

Invalid use of Property and it is shading what is in bold below.  

Set Me.RecordSource = rst

This is the updated code:

    Dim rst As ADODB.Recordset
    Dim strSql As String
    Dim strList As String
       
    Set cnn = CurrentProject.Connection
         
           strSql = "SELECT Number, PrimaryKey, ServCat, QualDesc, SeqID, AndOr, RevFrom, RevTo, ProcFrom, ProcTo, POSFrom, POSTo, RiskComp, " _
        & "Div, Sequence, Column, CreationDate, ModificationDate, Status, Comment " _
        & "FROM tblServCatData " _
        & "WHERE ServCat = '" & txtServCatView & "'"
                         
    Debug.Print strSql
                         
    Set rst = New ADODB.Recordset
    rst.Open strSql, cnn, adOpenKeyset, adLockOptimistic, adCmdText
     
    Set Me.RecordSource = rst
                 
    Set rst = Nothing
0
 
LVL 119

Accepted Solution

by:
Rey Obrero earned 500 total points
Comment Utility
you can use a listbox for this purpose

Dim rst As ADODB.Recordset
    Dim strSql As String
    Dim strList As String
       
    Set cnn = CurrentProject.Connection
         
           strSql = "SELECT Number, PrimaryKey, ServCat, QualDesc, SeqID, AndOr, RevFrom, RevTo, ProcFrom, ProcTo, POSFrom, POSTo, RiskComp, " _
        & "Div, Sequence, Column, CreationDate, ModificationDate, Status, Comment " _
        & "FROM tblServCatData " _
        & "WHERE ServCat = '" & txtServCatView & "'"
                         
    Debug.Print strSql
                         
    Set rst = New ADODB.Recordset
    rst.Open strSql, cnn, adOpenKeyset, adLockOptimistic, adCmdText

    set me.listboxName.recordset=rst
0
 

Author Comment

by:ScootterP
Comment Utility
Unfortunately there are too many records for a list box. I tried that.
0
Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

 
LVL 119

Expert Comment

by:Rey Obrero
Comment Utility
ok,
change this

Set Me.RecordSource = rst

with

Set Me.Recordset = rst
0
 

Author Comment

by:ScootterP
Comment Utility
Well, I don't get an error, but it is not showing anything.  Leaving, won't look at any reply until later tonight.
0
 
LVL 119

Assisted Solution

by:Rey Obrero
Rey Obrero earned 500 total points
Comment Utility
create a datasheet form with record source of

SELECT Number, PrimaryKey, ServCat, QualDesc, SeqID, AndOr, RevFrom, RevTo, ProcFrom, ProcTo, POSFrom, POSTo, RiskComp,  Div, Sequence, Column, CreationDate, ModificationDate, Status, Comment  FROM tblServCatData  WHERE 1=0

that will make your datasheet form bound but no records to show.


place your datasheet form as a subform in your form

now after getting the recordset, place this codes

                   set me.subformControlName.form.recordset=rst


if you still having problem, upload a copy of your db
0
 
LVL 119

Expert Comment

by:Rey Obrero
Comment Utility
0
 

Author Closing Comment

by:ScootterP
Comment Utility
I don't have time to work on this anymore, i am going to just dump it into a table and view the table.  Thank you for spenidng time on this.

Scott
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

The first two articles in this short series — Using a Criteria Form to Filter Records (http://www.experts-exchange.com/A_6069.html) and Building a Custom Filter (http://www.experts-exchange.com/A_6070.html) — discuss in some detail how a form can be…
Introduction When developing Access applications, often we need to know whether an object exists.  This article presents a quick and reliable routine to determine if an object exists without that object being opened. If you wanted to inspect/ite…
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now