In Access 2000 this doesn't work" Dim db As Database" what do I u.

V

Vickyav

In Access 97 I used this statement to open a record set...
Dim db As Database

I get an error on this portion and can't go any further. Can someone help me?
 
R

Rick Brandt

Vickyav said:
In Access 97 I used this statement to open a record set...
Dim db As Database

I get an error on this portion and can't go any further. Can someone help me?

"Database" is a DAO object. Access 97 and Access 2003 include a reference to
the DAO library by default. Access 2000 and Access 2002 do not so you have to
add it yourself.

While in the VBA window, go to Tools - References. Scan down the list until you
find the DAO 3.6 library and check it. If you don't plan on using the ADO
library that will already be checked by default then uncheck it. You can have
them both checked, but there are a handful of objects that exist in both
libraries so you would have to disambiguate them in your code by (for example),
using DAO.Recordset instead of just Recordset.
 
V

Vickyav

Thanks. It partially answered my question, but the code still doesn't work.
I've just begun to use 2000. Here is the code, can you tell me what is wrong?
It opens the same recordset twice. It loops to see if a beginning date is
null, if so, it puts that end date in the crrect end date of the first
recordset. It worked fine in 97
Private Sub Form_Load()
Dim db As DAO.Database

Dim rst1 As DAO.Recordset
Dim rst2 As DAO.Recordset

Set db = CurrentDb

Set rst1 = db.OpenRecordset("t_primary_correct")
Set rst2 = db.OpenRecordset("t_primary_correct")

rst1.MoveFirst
rst2.MoveFirst
rst1.MoveNext
Do
If rst2![Client_ID] = rst1![Client_ID] And _
rst2![id] > rst1![id] And _
IsNull(rst2![Restraint_Begin_Date]) Then
With rst1
.Edit
rst1![crrect_end date] = rst2![Restraint_End_Date]

.Update

End With
Else
rst1.MoveNext
With rst1
.Edit
rst1![crrect_end date] = rst1![Restraint_End_Date]
.Update
End With
End If

rst1.MoveNext
rst2.MoveNext
Loop Until rst1.EOF

End Sub
 
R

Rick Brandt

Vickyav said:
Thanks. It partially answered my question, but the code still doesn't work.
I've just begun to use 2000. Here is the code, can you tell me what is wrong?
It opens the same recordset twice. It loops to see if a beginning date is
null, if so, it puts that end date in the crrect end date of the first
recordset. It worked fine in 97 [SNIP]

I'm afraid you'll have to define "doesn't work".

Does the code not compile?
Do you get errors when you run it?
Does it run, but with incorrect results?
 
V

Vickyav

It doesn't run. The form opens and nothing runs.

Rick Brandt said:
Vickyav said:
Thanks. It partially answered my question, but the code still doesn't work.
I've just begun to use 2000. Here is the code, can you tell me what is wrong?
It opens the same recordset twice. It loops to see if a beginning date is
null, if so, it puts that end date in the crrect end date of the first
recordset. It worked fine in 97 [SNIP]

I'm afraid you'll have to define "doesn't work".

Does the code not compile?
Do you get errors when you run it?
Does it run, but with incorrect results?
 
R

Rick Brandt

Vickyav said:
It doesn't run. The form opens and nothing runs.

Are you sure that the OnLoad property has "[Event Procedure]" entered in it?

Have you tried inserting a break point to see if the code is even being
executed?
 
V

Vickyav

yes. to both questions. the last part has begun to work, but it is entering
the date to the wrong record, so I have it written wrong obviously.
if you see a mistake, let me know. Thanks so much for your help.

Rick Brandt said:
Vickyav said:
It doesn't run. The form opens and nothing runs.

Are you sure that the OnLoad property has "[Event Procedure]" entered in it?

Have you tried inserting a break point to see if the code is even being
executed?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top