Function does not work

  • Thread starter Thread starter morna
  • Start date Start date
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
 
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
 
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.
 
Back
Top