INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

VBA code working for me but not for users

VBA code working for me but not for users

(OP)
Hello everyone! I have a database that is used by multiple users. Every button and module works as intended except one. I have a hyperlink field that when clicked, it opens a report using the selected record's ID, attaches it to an email and closes the report afterwards. It works wonderful for me, but not for the other users. I have checked that all MS Access, Outlook and Windows versions are the same, libraries are the same, etc. It's the exact same front end, and all other modules work just fine.

I found out the problem is that when clicked, it doesn't run the "Open report" command at all. Any ideas?

Here's the code:

CODE --> VBA

Private Sub txtOpen_Click()

On Error GoTo ErrorHandler

  Me.Dirty = False
   'error check if the ID is null
If IsNull(Me!Req_ID) Then
MsgBox "Please select a valid record", _
vbOKOnly, "Error"
Exit Sub
End If
'Open report so it passes on the ID and shows the Doc for selected record
DoCmd.OpenReport "Qualification Document", acViewReport, , _
"Req_ID = " & Me!Req_ID
'Attaches the report to an email ready to send
 DoCmd.SendObject acSendReport, "Qualification Document", acFormatPDF, _
     Me.[E-mail Address], , , "Document for " & [Contact Name], "Find attached the document.", True
'close report after sending email
   DoCmd.Close acReport, "Qualification Document", acSaveNo
   MsgBox "Message Sent Successfully."
   
Cleanup:
   DoCmd.Close acReport, "Qualification Document", acSaveNo
   Exit Sub
'catches error if the user closes email without sending
ErrorHandler:
   Select Case Err.Number
     Case 2501
       MsgBox "Email message was Cancelled."
     Case Else
       MsgBox Err.Number & ": " & Err.Description
   End Select
   Resume Cleanup

End Sub 

RE: VBA code working for me but not for users

Quote:



I found out the problem is that when clicked, it doesn't run the "Open report" command at all. Any ideas?

How did you find out? What is it doing instead? Does it error, does it skip it?

RE: VBA code working for me but not for users

Also while I have seen people use docmd.open report to filter before doing something else with the report like e-mail it or export it, I always have always included my filter logic in the query in those cases and used send or export directly. This may just be a style and way I learned it thing but I have long running success the other way.

RE: VBA code working for me but not for users

(OP)
I took the "Error Handler" out, and when the person clicks on the field, it stops the macro and highlights in yellow this portion: "DoCmd.OpenReport "Qualification Document", acViewReport, , _"

With the error handler, when the person clicks on the field, nothing opens and it goes directly to the "Email message was Cancelled." error message.

RE: VBA code working for me but not for users

A phantom break point.

Sometimes break points don't clear correctly. Try setting a break point there, saving, close open, clear the break point and resave.

The one person I read with speculation of the cause is setting breakpoints when the code is executing/stepping through it.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close