'Dim' ing a Database object

  • Thread starter Thread starter LyonA
  • Start date Start date
L

LyonA

Guest
I am currently havinbg a problem with a function within an Access 95 module.

The problem code looks like this:

1> Function AddNewResponse()
2>
3>
4> On Error GoTo AddError
5>
6> Dim db As DATABASE
7> Dim rs As Recordset
8>
9> Set db = CurrentDb()
10> Set rs = db.OpenRecordset("Response", DB_OPEN_TABLE)
11>
12> rs.AddNew ' Add the new record
13>
14> rs!Name = Forms![update incident]!RName
15> rs!Date = Forms![update incident]!RDate
16> rs!Time = Forms![update incident]!RTime
17> rs!Response = Forms![update incident]!RDesc
18> rs![Incident Number] = Forms![update incident]![Incident Number]
19> rs![Series Identity] = Forms![update incident]![Series Identity]
20>
21> rs.UPDATE
22> rs.Close
23>
24> Exit Function
25>AddError:

The problem is that line 6 is not working as it should be creating db as a DAO database object, instead it appears to be creating a VBA DATABASE statement.

This line is in one version of the database which works fine (this database is a standalone database), however, in the current multi-user database the function does not work. I have checked that the references are pointing to the same things and they are, but the problem still occurs in the newer db.

If there is anyone who is able to help please email me
 
Thanks for the suggestion, however, it didn’t seem to do anything.

Please let me know if you have any other suggestions
 
You also may need to make sure that you have the DAO dll regestered and included in your references.
 
I have checked and I have got the dll referenced.

The strange thing is I have an older version of this database and the same function is in that, yet the Dim statement works correctly. I have checked the references in that database and matched my current DB with that.
 
When using

Set db=CurrentDB

you definately do not open a DAO-database, but this - current - i.e. JET-database.
Did you want do open your own database - which is not connected but this current one -
again with DAO? Why?
Normally DAO is only worth when accessing other databases (connected).

Just open as VBA database - why not?
 

Users who are viewing this thread

Back
Top Bottom