Function does not work

M

morna

I the below function behind a field in a form in Access 2003 - but I
can't seem to get it to work. The function fires on the Save Event,
but then errors on the OpenDatabase(....) - I have checked the name of
the database and that is fine.

Any thoughts?

Thanks for your time.


Private Function DischargeDateUpdated()
'Create variables
Dim dbMyDB As Database
Dim rsMyRS As recordSet

Set dbMyDB = OpenDatabase("MST_Referral_Tracking.mdb")
'Debug only
MsgBox "dbopen", vbOKOnly
Set rsMyRS = dbMyDB.OpenRecordset("FollowUp", dbOpenDynaset)
'Debug only
MsgBox "recordset open", vbOKOnly

'Debug only
MsgBox "DischargeDateUpdate function ran.", vbInformation
End Function
 
J

Jeff Boyce

Morna

Is the database being opened located in the same directory as the database
running the code?

Have you checked Access HELP for the exact syntax required for the
OpenDatabase() command? Do you need a fully-qualified pathname?

Regards

Jeff Boyce
Microsoft Office/Access MVP
 
F

fredg

I the below function behind a field in a form in Access 2003 - but I
can't seem to get it to work. The function fires on the Save Event,
but then errors on the OpenDatabase(....) - I have checked the name of
the database and that is fine.

Any thoughts?

Thanks for your time.

Private Function DischargeDateUpdated()
'Create variables
Dim dbMyDB As Database
Dim rsMyRS As recordSet

Set dbMyDB = OpenDatabase("MST_Referral_Tracking.mdb")
'Debug only
MsgBox "dbopen", vbOKOnly
Set rsMyRS = dbMyDB.OpenRecordset("FollowUp", dbOpenDynaset)
'Debug only
MsgBox "recordset open", vbOKOnly

'Debug only
MsgBox "DischargeDateUpdate function ran.", vbInformation
End Function

Try it his way.

Dim dbMyDB As DAO.Database
Dim rsMyRS As DAO.recordSet

Make sure you have a reference set to the DAO library.
 

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