Results 1 to 5 of 5
  1. #1
    Nishy is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Feb 2014
    Posts
    3

    Unhappy Module executes but then Hangs Access

    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

  2. #2
    amrut is offline Expert
    Windows 7 64bit Access 2010 32bit
    Join Date
    Jun 2012
    Location
    Dubai
    Posts
    614
    Is it because the word "Version" is a reserved word. See http://allenbrowne.com/AppIssueBadWord.html
    Try replacing the word Version with say VersionNumber. Does it works ?

  3. #3
    Nishy is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Feb 2014
    Posts
    3
    Thanks Amrut I replaced the word version to versionNumber and it still hangs.

    Do I Need to check the references for Microsoft DAO 3.6 Object Library? Because when I try to I get an error saying "Name conflicts with existing module, project, or object library".These are the references I currently have:

    Regards

    Daryl


  4. #4
    amrut is offline Expert
    Windows 7 64bit Access 2010 32bit
    Join Date
    Jun 2012
    Location
    Dubai
    Posts
    614
    Do I Need to check the references for Microsoft DAO 3.6 Object Library?
    I don't think so. How do you call the function ?
    Further put breakpoints in your code to find out the line at which access hangs.
    you can use Debug.Print too

  5. #5
    Nishy is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Feb 2014
    Posts
    3
    The problem was with the DoCmd.Echo False, "" command this was causing issues with the form not reloading - once this line was removed BINGO works fine. Thanks

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 4
    Last Post: 12-19-2013, 01:18 PM
  2. Access front end hangs when more than one user
    By mafrank101 in forum Access
    Replies: 3
    Last Post: 05-31-2012, 10:15 PM
  3. Print Preview Hangs
    By ellenl5974 in forum Reports
    Replies: 3
    Last Post: 05-08-2012, 05:17 PM
  4. Refreshing Linked Tables Hangs
    By blamb in forum Access
    Replies: 0
    Last Post: 12-05-2011, 12:36 PM
  5. Replies: 5
    Last Post: 02-08-2011, 11:17 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums