Database Error for Access 2007

J

Jenn

When running a macro (in Access 2007) that’s updating a query and making a
table, the following error occurs:

“Cannot open database “query nameâ€. It may not be a database that your
application recognizes, or the file may be corruptâ€.

The macro is located on the main form of the database. When the database is
closed, reopened and the macro is reran, the error does not occur. This
database is located on a network drive. Does anyone know what would cause
this issue? And why it would occur and then not occur once the database is
reopened?

Any thoughts or suggestions on this issue would be greatly appreciated.

Thank you in advance for your assistance.

Jenn
 
D

Daryl S

Jenn -

Can you post the code for the macro? You can also make a copy of your
database and convert your macro to code, which will allow you to step through
it and maybe find the error there...
 
J

Jenn

Daryl,

Here is the code for the Query and the Macro. Let me know your thoughts.
Thank you for your assistance.

SQL for Query:

SELECT "" AS [Payment Source], [Test GRANT ACTIVITY TABLE].EXP_TR_CODE,
[Test GRANT ACTIVITY TABLE].EXP_TR_NUM_AGY, [Test GRANT ACTIVITY
TABLE].EXP_TR_NUM_NUM, [Test GRANT ACTIVITY TABLE].FUND, [Test GRANT ACTIVITY
TABLE].FED_AID_CAT_NUM, [Test GRANT ACTIVITY TABLE].AGENCY, [Test GRANT
ACTIVITY TABLE].ACTIVITY, [Test GRANT ACTIVITY TABLE].OBJECT, [Test GRANT
ACTIVITY TABLE].SUB_OBJECT, [Test GRANT ACTIVITY TABLE].REPORTING_ORG_2,
[Test GRANT ACTIVITY TABLE].Comments, [Test GRANT ACTIVITY
TABLE].FED_AID_NUM, [Test GRANT ACTIVITY TABLE].Year, [Test GRANT ACTIVITY
TABLE].Month, [Test GRANT ACTIVITY TABLE].ACCEPTANCE_DATE, [Test GRANT
ACTIVITY TABLE].FED_AID_STATUS, [Test GRANT ACTIVITY TABLE].BUDGET_OBJ_CLS,
[Test GRANT ACTIVITY TABLE].EXPENDED_AMT,
IIf([Comments]="NETWORK",[EXPENDED_AMT],0) AS Network,
IIf([Comments]="PS",[EXPENDED_AMT],0) AS [Personal Services],
IIf([Comments]="EE",[EXPENDED_AMT],0) AS [E & E],
IIf([Comments]="FRINGE",[EXPENDED_AMT],0) AS Fringe,
IIf([Comments]="REFUND",[EXPENDED_AMT],0) AS Refunds,
IIf([Comments]="REVENUE",[EXPENDED_AMT],0) AS Revenue,
IIf([Comments]="INDIRECT",[EXPENDED_AMT],0) AS Indirect,
IIf([Comments]="WAN",[EXPENDED_AMT],0) AS Wan, 0 AS Allocations,
IIf([Comments]="",[EXPENDED_AMT],0) AS [Misc Other],
[Fringe]+[Indirect]+[Network]+[Wan]+[E & E]+[Personal Services] AS Total, ""
AS [Manual Adjustment], 0 AS [Revenue Adj], 0 AS [Refund Adj], 0 AS [Total
Receipt Adj], 0 AS [Personal Services Adj], 0 AS [Fringe Adj], 0 AS [Indirect
Adj], 0 AS [Other Expenditures Adj], 0 AS [Network Adj], 0 AS [WAN Adj], 0 AS
[Allocations Adj], 0 AS [Total Exp Adj], 0 AS [Total Receipts] INTO [Test
Grant Activity Reformat Table]
FROM [Test GRANT ACTIVITY TABLE];


Visual Basic code for button:

Private Sub Run_Grant_Reformat_Query_Click()
On Error GoTo Err_Run_Grant_Reformat_Query_Click

Dim stDocName As String

stDocName = "Test Grant Activity Reformat Query"
DoCmd.OpenQuery stDocName, acNormal, acEdit

Exit_Run_Grant_Reformat_Query_Click:
Exit Sub

Err_Run_Grant_Reformat_Query_Click:
MsgBox Err.Description
Resume Exit_Run_Grant_Reformat_Query_Click

End Sub
 

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