jcheath
asked on
microsoft office access can't open the database because it is missing
When using code to open a access database through Outlook, i get the following error: microsoft office access can't open the database because it is missing.
Sub PullMembershipUpdate(MyMail As MailItem)
Dim path As String
On Error Resume Next 'temporary error handling
Set objAccess = GetObject(, "Access.Application")
If Err <> 0 Then 'no existing instances of Access
Set objAccess = CreateObject("Access.Application")
End If
On Error GoTo PullMembershipUpdate_ErrHandler 'normal error handler
'ShowAccess Instance:=objAccess, Size:=SW_MAXIMIZE
With objAccess
path = "M:\Sams_Membership\Database\Blitz2008.mdb"
If .DBEngine.Workspaces(0).Databases.Count = 0 Then
.OpenCurrentDatabase FilePath:=path
ElseIf LCase(Right(.CurrentDb.Name, Len("Blitz2008.mdb"))) _
<> "Blitz2008.mdb" Then
.CloseCurrentDatabase
.OpenCurrentDatabase FilePath:=path
End If
.DoCmd.OpenForm FormName:="Update/EMail"
.Forms("Update/Email").SetFocus
If Date <= "10/17/2008" Then
.Forms("Update/Email").GoalDate = "10/17/2008"
Else
.Forms("Update/Email").GoalDate = Format(Date, "mm/dd/yyyy")
End If
End With
'Access.Forms("Update/Email").Command0
'objAccess.Forms("Update/Email").RunUpdateButton.Click
Access.Application.DoCmd.RunMacro ("RunUpdate")
'Access.Application.CurrentDb.Name
'Call BuildTreoFriendlyFeed
Access.Application.Run ("BuildTreoFriendlyFeed")
Exit Sub
PullMembershipUpdate_ErrHandler:
MsgBox Error$(), , "Open Database"
End Sub
Is "M:\Sams_Membership\Databa se\Blitz20 08.mdb" a valid path to the DB?
ASKER
Yes.
Where, exactly, does the error occur in your code?
What version of Office? Of Access?
Is the DB an MDB file?
What version of Office? Of Access?
Is the DB an MDB file?
ASKER
This is where it occurs: On Error GoTo PullMembershipUpdate_ErrHa ndler 'normal error handler
'ShowAccess Instance:=objAccess, Size:=SW_MAXIMIZE
With objAccess
path = "M:\Sams_Membership\Databa se\Blitz20 08.mdb"
I am using Office 2007 and Access 2003
The DB is in Access so im assuming it is a MDB file.
'ShowAccess Instance:=objAccess, Size:=SW_MAXIMIZE
With objAccess
path = "M:\Sams_Membership\Databa
I am using Office 2007 and Access 2003
The DB is in Access so im assuming it is a MDB file.
>>This is where it occurs: On Error GoTo PullMembershipUpdate_ErrHa ndler 'normal error handler
Does the label PullMembershipUpdate_ErrHa ndler exist? Otherwise that doesn't sound like the problem.
I asked "where, exactly" and you supplied a comment line plus two code lines, niether of which would account for your "missing" DB error message.
Care to try again?
Does the label PullMembershipUpdate_ErrHa
I asked "where, exactly" and you supplied a comment line plus two code lines, niether of which would account for your "missing" DB error message.
Care to try again?
ASKER
Well, in that case, i guess im not exactly sure where it occurs.
I assumed that since the code says:
On Error GoTo PullMembershipUpdate_ErrHa ndler
and after the Exit Sub it says:
PullMembershipUpdate_ErrHa ndler:
MsgBox Error$(), , "Open Database"
End Sub
That that was where the error was coming from. Sorry for the confusion. But i cant tell excatly where it is coming from.
I assumed that since the code says:
On Error GoTo PullMembershipUpdate_ErrHa
and after the Exit Sub it says:
PullMembershipUpdate_ErrHa
MsgBox Error$(), , "Open Database"
End Sub
That that was where the error was coming from. Sorry for the confusion. But i cant tell excatly where it is coming from.
>>But i cant tell excatly where it is coming from.
Sure you can. Immediately after the Dim path As String statement, add a line with STOP as the command. Now when the function is invoked, the debugger will stop at that line.
Press F8 to step through the code, or F5 to continue with no further interaction.
Sure you can. Immediately after the Dim path As String statement, add a line with STOP as the command. Now when the function is invoked, the debugger will stop at that line.
Press F8 to step through the code, or F5 to continue with no further interaction.
ASKER
Okay. When doing so, it shows an error on:
On Error Resume Next
THis may sound stupid but im assuming the yellow line indicates error?
On Error Resume Next
THis may sound stupid but im assuming the yellow line indicates error?
No, that indicates the line to be executed. When the error occurs, it should goto your handler.
ASKER
Okay. Here is where it went to the handler:
.OpenCurrentDatabase FilePath:=path
.OpenCurrentDatabase FilePath:=path
Then that is where the problen lies.
Either the syntax is incorrect or the FilePath parameter is incorrect (or expecting something else). What does Google say about OpenCurrentDatabase ?
Either the syntax is incorrect or the FilePath parameter is incorrect (or expecting something else). What does Google say about OpenCurrentDatabase ?
ASKER
Here is something i've found:
Syntax
application.OpenCurrentDat abase dbname[, exclusive]
Perhaps the pathing is wrong?
Syntax
application.OpenCurrentDat
Perhaps the pathing is wrong?
Press CTRL-G to open the immediate window, then type in
?path & "<"
and press Enter. That will display the value of path.
?path & "<"
and press Enter. That will display the value of path.
ASKER
This is what came back:
<
<
So then, path has no value, which would account for your "missing DB" error.
Where in the code are you, looking at your original post?
Where in the code are you, looking at your original post?
ASKER
Im not sure I understand the question. Can you clarify "where in the code are you"?
Looking at your original code post, what line caused the error?
ASKER
Here is what caused the error:
If .DBEngine.Workspaces(0).Da tabases.Co unt = 0 Then
.OpenCurrentDatabase FilePath:=path
If .DBEngine.Workspaces(0).Da
.OpenCurrentDatabase FilePath:=path
Move statement
path = "M:\Sams_Membership\Database\Blitz2008.mdb"
before the With..End With loop, re-run the code, and see if that makes a difference.
ASKER
Same thing/ Once it gets to .OpenCurrentDatabase FilePath:=path it errors out. Is there a different way that I should write the path?
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
ASKER
Whats intersting is taht i just ran it on another pc and it seems to be working fine.
Not sure how if path is blank?