Share via

"Could not find file" error message

Anonymous
2011-09-26T20:58:14+00:00

I've been having some problems with this code and I can't figure out why it's giving me this error message: "Could not find the file '<path>\3.mdb'. It's looking for a mdb called '3' on my desktop (I replaced the actual path with '<path>' in the error message). I don't have a database named that. I've checked the back end paths and everything appears to be linked fine. I run other codes and don't have any problems, just this one. It gives me the error message after I click Yes in the Message box.

What's odd is that I took the same code for an OutputTo function and just adjusted the actions to send an email instead.

Any ideas?

  Dim dbs As DAO.Database

  Dim qdf As DAO.QueryDef

  Dim prm As DAO.Parameter

  Dim rs As DAO.Recordset

  Set dbs = CurrentDb

  Set qdf = dbs.QueryDefs("BlowIn_qryDistinct")

  For Each prm In qdf.Parameters

        prm = Eval(prm.Name)

  Next prm

  Set rs = qdf.OpenRecordset

On Error GoTo Err_PO_Click

If MsgBox("Issue Grids?", vbYesNo + vbQuestion, "Confirmation Required") = vbYes Then <ERROR MESSAGE APPEARS AFTER CLICKING "YES">

    rs.MoveFirst

   Do Until rs.EOF

        DoCmd.CopyObject acReport, rs![EventTitle] & " 2012 Blow In Grids " & Format(Now(), "MM-DD-YY"), acReport, "BlowIn_rptGrid"

        DoCmd.OpenReport rs![EventTitle] & " 2012 Blow In Grids " & Format(Now(), "MM-DD-YY"), acViewPreview, , "EventTitle = """ & rs!EventTitle & """"

        DoCmd.SendObject acSendReport, rs![EventTitle] & " 2012 Blow In Grids " & Format(Now(), "MM-DD-YY"), acFormatPDF, rs!EmailTo, rs!EmailCC, , rs!EventTitle & " 2012 Blow In Grids", "Please find the latest blow in grids attached. Thank you.", True

        DoCmd.Close acReport, rs![EventTitle] & " 2012 Blow In Grids " & Format(Now(), "MM-DD-YY"), acSaveNo

        DoCmd.DeleteObject acReport, rs![EventTitle] & " 2012 Blow In Grids " & Format(Now(), "MM-DD-YY")

    rs.MoveNext

    Loop

End If

Exit_PO_Click:

    MsgBox ("Grids Issued")

    rs.Close

    Set rs = Nothing

    Set dbs = Nothing

    Exit Sub

Err_PO_Click:

    MsgBox Err.Description

    Resume Exit_PO_Click

Microsoft 365 and Office | Access | For home | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

Answer accepted by question author

Tom van Stiphout 40,211 Reputation points MVP Volunteer Moderator
2011-09-27T03:14:48+00:00

You will need to use the debugger to find out more. Click in the margin of your code just below the MsgBox, and a red dot appears indicating a breakpoint. Run again and you will stop here, allowing you to step through the code and inspecting variables to make sure they are what you expected. This method also allows you to narrow down the error to EXACTLY the line with the offending code.

Was this answer helpful?

0 comments No comments

2 additional answers

Sort by: Most helpful
  1. Anonymous
    2011-09-27T15:42:04+00:00

    Fascinating bug, and yes that would have been perplexing.

    It was asking for 3.mdb because the value of the builtin constant acReport happens to be... 3!

    Was this answer helpful?

    0 comments No comments
  2. Anonymous
    2011-09-27T14:00:30+00:00

    Thanks. That did help me isolate the problem. I found the error in this line:

    DoCmd.CopyObject acReport, rs![EventTitle] & " 2012 Blow In Grids " & Format(Now(), "MM-DD-YY"), acReport, "BlowIn_rptGrid"

    I had "acReport" in there twice. I needed to remove the first mention of it and it worked just fine.

    Was this answer helpful?

    0 comments No comments