Runtime Issue (2 Viewers)

Pete490h

Member
Local time
Today, 16:32
Joined
Jan 18, 2021
Messages
59
Hi,
I have a new event procedure (below) which works absolutely fine for me but fails on my two Runtime users
Has anyone had similar issues with Runtime as its the first time its happenened to me

Just wonder if anyone can see any issues thanks


Private Sub InTest_Click()


'STATUS "Deleting Previous Import Table" - STAGE1

On Error Resume Next

DoCmd.DeleteObject acTable, "NISFeatureData2"

On Error GoTo 0



'IMPORTING SHEET - STAGE2

'DoCmd.TransferSpreadsheet acImport, , "NISFeatureData2",

"C:\Users\accounts_2\OneDrive - PM\NIS-IRN\" & Me.CustomerIRN & ".xlsx", False



'DELETING HEADER ROWS - STAGE3

Dim rs As Recordset, done As Boolean, S As String

Set rs = CurrentDb.OpenRecordset("NISFeatureData2")

done = False

While Not rs.EOF And Not done

S = Nz(rs!F1, "")

If S = "Dim" Then done = True

rs.Delete

rs.MoveNext

Wend

rs.Close



'LOOP THRU VALID Dim

Dim FoundEnd As Boolean

Set rs = CurrentDb.OpenRecordset("NISFeatureData2")

FoundEnd = False

While Not rs.EOF

S = Nz(rs!F1, "")

If S = "Comments & Photos:" Then FoundEnd = True

If FoundEnd Then rs.Delete

rs.MoveNext

Wend

rs.Close

Set rs = Nothing



'UPDATE FEATURE DATA - STAGE4

DoCmd.OpenQuery "NISFeatureDataAQ", acViewNormal, acReadOnly

DoCmd.RunCommand acCmdRun



DoCmd.OpenQuery "NISFeatureData1UQ", acViewNormal, acReadOnly

DoCmd.RunCommand acCmdRun



DoCmd.RunMacro "NISNextRecordBack1"



DoCmd.RunMacro "NISFeatureTextRemove1"



DoCmd.RunMacro "NISNextRecordBack1"





'UPDATE COMPONENTS - STAGE5

Dim db As DAO.Database

Set db = CurrentDb()



DoCmd.RunMacro "NISNextRecordBack1"

Wait 1

DoCmd.RunMacro "NISAppComponentNumber1"

Wait 1



Me.CompQty.SetFocus

If Me.CompQty & "" > 0 And Me.CompQty <= DMax("TallyNum", "tblTallyNumbers") Then

Else

MsgBox " Component Qty is required and must be <= the Max value in tblTallyNumbers", vbOKOnly

Me.CompQty.SetFocus

Exit Sub

End If



'UPDATE INSPECTION - STAGE6

DoCmd.RunMacro "NISAppItemComp1"

Wait 1

DoCmd.RunMacro "NextRecordNISComp1"

Wait 1



'HIDE INTEST BUTTON - STAGE7

OrderNumber.SetFocus

InTest.Enabled = False

InTest.Transparent = True



End Sub
 
That's quite a wall of text.
I've removed the white space and indented it :
Rich (BB code):
'STATUS "Deleting Previous Import Table" - STAGE1
    On Error Resume Next
    DoCmd.DeleteObject acTable, "NISFeatureData2"
    On Error GoTo 0
    'IMPORTING SHEET - STAGE2
    'DoCmd.TransferSpreadsheet acImport, , "NISFeatureData2",    "C:\Users\accounts_2\OneDrive - PM\NIS-IRN\" & Me.CustomerIRN & ".xlsx", False
    'DELETING HEADER ROWS - STAGE3
    Dim rs As Recordset, done As Boolean, S As String
    Set rs = CurrentDb.OpenRecordset("NISFeatureData2")
    done = False
    While Not rs.EOF And Not done
        S = Nz(rs!F1, "")
        If S = "Dim" Then done = True
        rs.Delete
        rs.MoveNext
    Wend
    rs.Close
    'LOOP THRU VALID Dim
    Dim FoundEnd As Boolean
    Set rs = CurrentDb.OpenRecordset("NISFeatureData2")
    FoundEnd = False
    While Not rs.EOF
        S = Nz(rs!F1, "")
        If S = "Comments & Photos:" Then FoundEnd = True
        If FoundEnd Then rs.Delete
        rs.MoveNext
    Wend
    rs.Close
    Set rs = Nothing
    'UPDATE FEATURE DATA - STAGE4
    DoCmd.OpenQuery "NISFeatureDataAQ", acViewNormal, acReadOnly
    DoCmd.RunCommand acCmdRun
    DoCmd.OpenQuery "NISFeatureData1UQ", acViewNormal, acReadOnly
    DoCmd.RunCommand acCmdRun
    DoCmd.RunMacro "NISNextRecordBack1"
    DoCmd.RunMacro "NISFeatureTextRemove1"
    DoCmd.RunMacro "NISNextRecordBack1"
    'UPDATE COMPONENTS - STAGE5
    Dim db As DAO.Database
    Set db = CurrentDb()
    DoCmd.RunMacro "NISNextRecordBack1"
    Wait 1
    DoCmd.RunMacro "NISAppComponentNumber1"
    Wait 1
    Me.CompQty.SetFocus
    If Me.CompQty & "" > 0 And Me.CompQty <= DMax("TallyNum", "tblTallyNumbers") Then
    Else
        MsgBox " Component Qty is required and must be <= the Max value in tblTallyNumbers", vbOKOnly
        Me.CompQty.SetFocus
        Exit Sub
    End If
    'UPDATE INSPECTION - STAGE6
    DoCmd.RunMacro "NISAppItemComp1"
    Wait 1
    DoCmd.RunMacro "NextRecordNISComp1"
    Wait 1
    'HIDE INTEST BUTTON - STAGE7
    OrderNumber.SetFocus
    InTest.Enabled = False
    InTest.Transparent = True
End Sub

Instead of the On Error Goto 0, I would suggest you use the error handling to pop up a message box with the error code, error description and error line, so you can see what it's failing on when run in the runtime?

I assume it compiles on your non runtime machines?
 
That's quite a wall of text.
I've removed the white space and indented it :
Rich (BB code):
'STATUS "Deleting Previous Import Table" - STAGE1
    On Error Resume Next
    DoCmd.DeleteObject acTable, "NISFeatureData2"
    On Error GoTo 0
    'IMPORTING SHEET - STAGE2
    'DoCmd.TransferSpreadsheet acImport, , "NISFeatureData2",    "C:\Users\accounts_2\OneDrive - PM\NIS-IRN\" & Me.CustomerIRN & ".xlsx", False
    'DELETING HEADER ROWS - STAGE3
    Dim rs As Recordset, done As Boolean, S As String
    Set rs = CurrentDb.OpenRecordset("NISFeatureData2")
    done = False
    While Not rs.EOF And Not done
        S = Nz(rs!F1, "")
        If S = "Dim" Then done = True
        rs.Delete
        rs.MoveNext
    Wend
    rs.Close
    'LOOP THRU VALID Dim
    Dim FoundEnd As Boolean
    Set rs = CurrentDb.OpenRecordset("NISFeatureData2")
    FoundEnd = False
    While Not rs.EOF
        S = Nz(rs!F1, "")
        If S = "Comments & Photos:" Then FoundEnd = True
        If FoundEnd Then rs.Delete
        rs.MoveNext
    Wend
    rs.Close
    Set rs = Nothing
    'UPDATE FEATURE DATA - STAGE4
    DoCmd.OpenQuery "NISFeatureDataAQ", acViewNormal, acReadOnly
    DoCmd.RunCommand acCmdRun
    DoCmd.OpenQuery "NISFeatureData1UQ", acViewNormal, acReadOnly
    DoCmd.RunCommand acCmdRun
    DoCmd.RunMacro "NISNextRecordBack1"
    DoCmd.RunMacro "NISFeatureTextRemove1"
    DoCmd.RunMacro "NISNextRecordBack1"
    'UPDATE COMPONENTS - STAGE5
    Dim db As DAO.Database
    Set db = CurrentDb()
    DoCmd.RunMacro "NISNextRecordBack1"
    Wait 1
    DoCmd.RunMacro "NISAppComponentNumber1"
    Wait 1
    Me.CompQty.SetFocus
    If Me.CompQty & "" > 0 And Me.CompQty <= DMax("TallyNum", "tblTallyNumbers") Then
    Else
        MsgBox " Component Qty is required and must be <= the Max value in tblTallyNumbers", vbOKOnly
        Me.CompQty.SetFocus
        Exit Sub
    End If
    'UPDATE INSPECTION - STAGE6
    DoCmd.RunMacro "NISAppItemComp1"
    Wait 1
    DoCmd.RunMacro "NextRecordNISComp1"
    Wait 1
    'HIDE INTEST BUTTON - STAGE7
    OrderNumber.SetFocus
    InTest.Enabled = False
    InTest.Transparent = True
End Sub

Instead of the On Error Goto 0, I would suggest you use the error handling to pop up a message box with the error code, error description and error line, so you can see what it's failing on when run in the runtime?

I assume it compiles on your non runtime machines?
Thanks for that, I’ll change and try asap and advise accordingly
Yes I compile the database on my PC
 
Does the Access version of the runtime machines differ to your development PC? If so, be sure to decompile the accdb before deploying it to them.
 
Does the Access version of the runtime machines differ to your development PC? If so, be sure to decompile the accdb before deploying it to them.
No they’re both Access 2021and I regularly decompile and compact
 
That's quite a wall of text.
I've removed the white space and indented it :
Rich (BB code):
'STATUS "Deleting Previous Import Table" - STAGE1
    On Error Resume Next
    DoCmd.DeleteObject acTable, "NISFeatureData2"
    On Error GoTo 0
    'IMPORTING SHEET - STAGE2
    'DoCmd.TransferSpreadsheet acImport, , "NISFeatureData2",    "C:\Users\accounts_2\OneDrive - PM\NIS-IRN\" & Me.CustomerIRN & ".xlsx", False
    'DELETING HEADER ROWS - STAGE3
    Dim rs As Recordset, done As Boolean, S As String
    Set rs = CurrentDb.OpenRecordset("NISFeatureData2")
    done = False
    While Not rs.EOF And Not done
        S = Nz(rs!F1, "")
        If S = "Dim" Then done = True
        rs.Delete
        rs.MoveNext
    Wend
    rs.Close
    'LOOP THRU VALID Dim
    Dim FoundEnd As Boolean
    Set rs = CurrentDb.OpenRecordset("NISFeatureData2")
    FoundEnd = False
    While Not rs.EOF
        S = Nz(rs!F1, "")
        If S = "Comments & Photos:" Then FoundEnd = True
        If FoundEnd Then rs.Delete
        rs.MoveNext
    Wend
Rich (BB code):
At the start of your code you delete "NISFeatureData2".
Then turn off error trapping in the function
Then open the now missing "NISFeatureData2" 
You may be able to to get away with it in Full Access but the un-handled error will crash runtime.

The the delete in the loop can also cause problems. You should replace it with a delete query.




rs.Close Set rs = Nothing 'UPDATE FEATURE DATA - STAGE4 DoCmd.OpenQuery "NISFeatureDataAQ", acViewNormal, acReadOnly DoCmd.RunCommand acCmdRun DoCmd.OpenQuery "NISFeatureData1UQ", acViewNormal, acReadOnly DoCmd.RunCommand acCmdRun DoCmd.RunMacro "NISNextRecordBack1" DoCmd.RunMacro "NISFeatureTextRemove1" DoCmd.RunMacro "NISNextRecordBack1" 'UPDATE COMPONENTS - STAGE5 Dim db As DAO.Database Set db = CurrentDb() DoCmd.RunMacro "NISNextRecordBack1" Wait 1 DoCmd.RunMacro "NISAppComponentNumber1" Wait 1 Me.CompQty.SetFocus If Me.CompQty & "" > 0 And Me.CompQty <= DMax("TallyNum", "tblTallyNumbers") Then Else MsgBox " Component Qty is required and must be <= the Max value in tblTallyNumbers", vbOKOnly Me.CompQty.SetFocus Exit Sub End If 'UPDATE INSPECTION - STAGE6 DoCmd.RunMacro "NISAppItemComp1" Wait 1 DoCmd.RunMacro "NextRecordNISComp1" Wait 1 'HIDE INTEST BUTTON - STAGE7 OrderNumber.SetFocus InTest.Enabled = False InTest.Transparent = True End Sub
Instead of the On Error Goto 0, I would suggest you use the error handling to pop up a message box with the error code, error description and error line, so you can see what it's failing on when run in the runtime?

I assume it compiles on your non runtime machines?
 

Users who are viewing this thread

Back
Top Bottom