Is this a corrupt database - or is it a different problem?

D

dhstein

I've been experiencing a problem that I thought was a symptom of a corrupt
database, but now I'm not so sure. The database works fine in normal
situations. However, if I compact and repair, then I get 1 specific error in
1 function. The code that executes is below:

Private Sub MakeCostChangeTable()

DoCmd.SetWarnings False

DoCmd.RunSQL "DELETE * FROM tblCostChanges;"

DoCmd.RunSQL "INSERT INTO tblCostChanges SELECT * FROM qryCostChanges;"

DoCmd.SetWarnings True

End Sub

The arrow (on debug) points to the INSERT INTO statement
The error I get is:
Run-time error '3049':

Cannot open database ". It may not be a database that your application
recognizes, or the file may be corrupt.

So I put back the backup copy before the Compact and repair and everything
works fine - including the code above. So at this point, I'm trying to
figure out how to proceed. Can anyone see anything wrong with the code above
that might cause a problem after a Compact and Repair? Thanks for any help
on this.
 
J

Jerry Whittle

I suggest putting in the SQL statement from qryCostChanges instead of the
reference to qryCostChanges.

Another thing to check is if the database code is compiled before doing the
compact and repair. If it isn't or work compile, there could be a problem.
 
T

Tony Toews [MVP]

dhstein said:
DoCmd.RunSQL "INSERT INTO tblCostChanges SELECT * FROM qryCostChanges;"

To add to Jerry's posting try square brackets around the tbl and qry
name. Although try the query name first.

Tony
 

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