Hi guys hoping somebody can help me
I am executing a module that gets a filename and path from an Access table and then opens that document in word. The module works fine but after it executes it freezes access and I have to close Access. Any help much appreciated.
Module 1 Called Path
Public Function GetLocation(Version) As String
Dim dbs As Database
Dim Lrs As DAO.Recordset
Dim LSQL As String
Dim LGST As String
'Open connection to current Access database
Set dbs = CurrentDb()
'Create SQL statement to retrieve value from GST table
Select Case Version
Case 1
LSQL = "SELECT QADocs.ID, QADocs.Path From QADocs WHERE (((QADocs.ID)=1))"
Case 2
LSQL = "SELECT QADocs.ID, QADocs.Path From QADocs WHERE (((QADocs.ID)=2))"
End Select
Set Lrs = dbs.OpenRecordset(LSQL)
'Retrieve value if data is found and select the Path field
If Lrs.EOF = False Then
LGST = Lrs("Path")
Else
LGST = "Not found"
End If
Lrs.Close
Set Lrs = Nothing
GetLocation = LGST
End Function
Module 2 Called Letters
Function Letters_AckNew()
On Error GoTo Letters_Ack_Err
DoCmd.RunCommand acCmdSaveRecord
DoCmd.SetWarnings False
DoCmd.Echo False, ""
DoCmd.OpenQuery "CurrentRecord", acViewNormal, acEdit
DoCmd.GoToControl "Ack"
If (Forms!Input![Circumstance?] = False) Then
Call Shell("Winword " & Path.GetLocation(2), 1)
End If
If (Forms!Input![Circumstance?] = True) Then
' Runs Word Acknowledgement_Letter_Template_Circ.doc
Call Shell("Winword " & Path.GetLocation(1), 1)
End If
Letters_Ack_Exit:
Exit Function
Letters_Ack_Err:
MsgBox Error$
Resume Letters_Ack_Exit
End Function