Access crash on option button click

J

JIM

Hi, I thought my database was damaged and went through all the steps to
restore: backup, compact/repair, etc. with no results. My goal is to print
pdf files from access. I also updated to the latest Adobe Reader. So I
created a new database with a form and an option button and used the same
code and got the same resulting message: “MSAccess has encountered a problem
and needs to close. We are sorry…..â€. I’m using A2000. Any idea to what is
wrong? Here’s my code:

Option Compare Database
Option Explicit

Public Const SW_Hide = 0
Public Const SW_Minimize = 6
Public Const SW_Restore = 9
Public Const SW_Show = 5
Public Const SW_ShowMazimized = 3
Public Const SW_ShowMinimized = 2
Public Const SW_ShowMinnoActive = 7
Public Const SW_Showna = 8
Public Const SW_ShownoActivate = 4
Public Const SW_ShowNormal = 1

Public Declare Function ShellExecute Lib "Shell32.dll" Alias "ShellExecuteA"
(ByVal hWnd As Long, ByVal IpOperation As String, ByVal IpParameters As
String, ByVal IpDirectory As String, ByVal nShowCmd As Long) As Long

Public Sub ExecuteFile(sFileName As String, sAction As String) 'sAction can
be either "Open" or "Print"
Dim vReturn As Long

If ShellExecute(Access.hWndAccessApp, sAction, sFileName, vbNullString,
SW_ShowNormal) < 33 Then
MsgBox "File not found"
End If
End Sub


I have a textbox in a subform named txtMapLoc and call my module from an
option button click:

Private Sub Option62_Click()
Dim sFileName As String
sFileName = Me.txtMapLoc
Call ExecuteFile(sFileName, "Print")
End Sub

Thanks
 

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