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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Replacement for Database data type 1

Status
Not open for further replies.

rocknrisk

Programmer
May 14, 2002
43
GB
Hi all,

I am rewriting a database with Access 2002 that was originally written with Access 97. I get a "User-defined type not defined" error. Here's the code:

...
Private Sub cbxClient_AfterUpdate()

Dim strSQL As String, strRestrict As String
Dim v As Variant, lngX As Variant
Dim dbs As Database, rst As Recordset, fld As Field, fld2 As Field

lngX = Forms![frmCallMonitoring]![cbxClient].Value
' Return reference to current database.
Set dbs = CurrentDb
strSQL = "SELECT *"
strSQL = strSQL & " FROM [tblClientWeighting]"
strSQL = strSQL & " WHERE [tblClientWeighting].[Client] = '" & lngX & "'"
' Open table-type Recordset object.
Set rst = dbs.OpenRecordset(strSQL)

'Set fld = rst.Fields!Courtesy1wgt
Me![txtOpeningWgt11].Value = rst.Fields!txtOpeningWgt11.Value
...

I must be doing something wrong - where do I define this data type. I'm a Java programmer, but have to do this project for work, so my VBA skills are not really sharp. Please help!!!

Thank you in advance.
Clinton[sadeyes]
"Finish what you started"
 
By default Access 97 uses DAO as it's database engine. Access 2000 & 2002 use ADO! What you need to do is add a reference to DAO 3.6 and change:
Dim dbs As Database, rst As Recordset, fld As Field, fld2 As Field

to

Dim dbs As DAO.Database, rst As DAO.Recordset, fld As DAO.Field, fld2 As DAO.Field

ADO has database, recordset, etc. properties, so you need to specify which data object you are using.
I don't use A2k myself, but from the posts I've seen around, it is probably better to use dao over ado.

Ben ----------------------------------
Ben O'Hara
bo104@westyorkshire.police.uk
----------------------------------
 
i use access 2k, and i use a mix, some things are much easier to do in dao, and others(though, not to many for me) are easier in ado... i'm learning them both at the same time because i got a db dropped in my lap and i had no knoldge... i find dao easier to deal with most of the time...

--James
JHauge@jmjpc.net
Life is change. To deny change is to deny life.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top