By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,392 Members | 1,561 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,392 IT Pros & Developers. It's quick & easy.

Successfully opening a Recordset

P: n/a
In the code section of the form that I am working on:
I am trying to obtain records from another table other than the one I
am using as the recordsource for the current form.

In other words, I am attempting to open and access records from the
Beverages table from the code of the "customer service form".
Code used below
---------------
Dim dbs As database, rstItems As Recordset

Set dbs = CurrentDb
Set rstItems = dbs.openrecordset("Beverages")
-------------------
End of code segment
However I am getting the following message
------------------------------------------
Compile Error:
User-defined type not defined

I have also noticed that the 'd' in database and the 'o' in
openrecordset are not automatically capitolizing.

Could someone please inform me of how I can successfully open a
recordset? Thanks in advance.

Nov 13 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a
<Mi***************@hotmail.com> wrote in message
news:11*********************@g14g2000cwa.googlegro ups.com...
In the code section of the form that I am working on:
I am trying to obtain records from another table other than the one I
am using as the recordsource for the current form.

In other words, I am attempting to open and access records from the
Beverages table from the code of the "customer service form".
Code used below
---------------
Dim dbs As database, rstItems As Recordset

Set dbs = CurrentDb
Set rstItems = dbs.openrecordset("Beverages")
-------------------
End of code segment
However I am getting the following message
------------------------------------------
Compile Error:
User-defined type not defined

I have also noticed that the 'd' in database and the 'o' in
openrecordset are not automatically capitolizing.

Could someone please inform me of how I can successfully open a
recordset? Thanks in advance.


It's probably because you don't have a DAO reference set. In the newer
versions of Access ADO and not DAO is the default. You will either need to
use ADO code, or simply go into Tools->References from the code window and
change the reference to DAO.
Nov 13 '05 #2

P: n/a
I couldn't find any reference to DAO from the reference or any of the
other menus in the code window. So I tried using ADO with the code
below.
Set conn = Server.CreateObject("ADODB.Connection")
conn.Provider = "Microsoft.Jet.OLEDB.4.0"
conn.Open "c:\jplum.mdb"
Set rs = Server.CreateObject("ADODB.recordset")
rs.Open "Beverages", conn

However I am getting the error message
---------------------------------------------------------
Run-time Error 424
Object Required

Nov 13 '05 #3

P: n/a
Is Beverages a table or query in your current database?

<Mi***************@hotmail.com> wrote in message
news:11**********************@g14g2000cwa.googlegr oups.com...
I couldn't find any reference to DAO from the reference or any of the
other menus in the code window. So I tried using ADO with the code
below.
Set conn = Server.CreateObject("ADODB.Connection")
conn.Provider = "Microsoft.Jet.OLEDB.4.0"
conn.Open "c:\jplum.mdb"
Set rs = Server.CreateObject("ADODB.recordset")
rs.Open "Beverages", conn

However I am getting the error message
---------------------------------------------------------
Run-time Error 424
Object Required

Nov 13 '05 #4

P: n/a
It is a Table.

FYI I am using Access 2000 on a Windows ME operating system.

Nov 13 '05 #5

P: n/a
<Mi***************@hotmail.com> wrote in message
news:11*********************@g14g2000cwa.googlegro ups.com...
It is a Table.

FYI I am using Access 2000 on a Windows ME operating system.


Something like this should work:
Dim cn As New ADODB.Connection
Dim rs As New ADODB.Recordset
Dim fld As Field

Set cn = CurrentProject.Connection

' This can be a query or simply a table
rs.Open("Beverages"), cn

' If you should want to list the fields
For Each fld In rs.Fields
Debug.Print fld.Name
Next

' Iterate through all of the records
While Not rs.EOF
'... do some stuff
rs.MoveNext
Wend
rs.Close
End Sub

Hope this helps. Let me know if not.
Nov 13 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.