473,387 Members | 1,388 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Successfully opening a Recordset

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
5 1421
<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
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
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
It is a Table.

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

Nov 13 '05 #5
<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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: mr_ocp | last post by:
Hi friends I need routines to create an excel file with worksheets for each customer and a text file as well for each customer, first worksheet would be a "Summary Report", here is the code that...
4
by: Niranjan | last post by:
I have an Access XP split application operating on Windows XP. I have a form that opens on Startup that opens the backend database and keeps it open until the application is closed. For the first...
3
by: JB | last post by:
Hello, I am trying to write a query that selects a row from another table with a field that matches the Me!RecordingID that's on the form. For some reason my query is not working and the recordset...
5
by: Mike C | last post by:
Hi. I'm trying to pull information from two databases on the same server and use that information on my web form. Not sure how to reference two separate databases. Any suggestions would be...
7
by: MLH | last post by:
Here's a blurb cut from A97 HELP on BOF/EOF: When you open a Recordset object that contains at least one record, the first record is the current record and the BOF and EOF properties are False;...
4
by: breadhead | last post by:
Good morning, all. I am creating an Access 2002 application to run on XP clients and I'm struggling with the task of testing whether a single-field record exists before allowing the user to add it...
1
by: omar.norton | last post by:
I am trying to create a from with a series of combo boxes that each query a different field (called Specific01, Specific02 etc., except the first field which is called Condition). Each combo box...
16
by: Phil Stanton | last post by:
I have a form with a button which is supposed to open an Excel file (With lots of Macros /VBA) in it. The Excel file gets it's data from the Access program Here is the code Private Sub...
7
by: KC-Mass | last post by:
I have a module that walks down a file of unique claim numbers. Db is Current db. For each claim number I want it to retrieve, to a recordset all the transactions related to that claim. The...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.