Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Recordset Error

Status
Not open for further replies.

puppygirl3939

Technical User
Sep 15, 2003
21
US
Please Help!!

I am new at VB code and I am following the instructions from a book. Line 3 (dim dbsA As database) returns the follwoing error: "Compile error:User-defined type not defined". Can someone please tell what am I doing wrong. The code is:

Private Sub County_Click()

Dim strregion As String
Dim dbsA As database
Dim recMain As Recordset
Set dbsA = CurrentDb
Set recMain = dbsA.OpenRecordset("Main")
End Sub

What I am trying to accomplish is to create a code where the user selects a county and it automatically enters the region in the region field. Both the county and the region are one to many tables and are subforms of the main form. Example form "Main" captures the company information subform "Counties" is where users select the number of "counties" that will receive the company information and subform "region" is populated base on the counties selected.
 
You might want to check your references. You'll note that the 'd' in database did not capitalize. This means that it cannot find the type 'database'.
Also, try to let the code know what library to pull from. For example, when dimming: Dim dbs as DAO.Database, Dim rst as DAO.Recordset
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top