Code:
Private Sub Form_Open(Cancel As Integer)
Dim tmpArgs As Variant, ffile As String, st1 As String
debug.print "Openargs=" & me.openargs
tmpArgs = Split(Nz(Me.OpenArgs, ""), "|") 'where the code stops running
pth1 = ""
If Not IsNull(tmpArgs) Then
pth1 = tmpArgs(0)
st1 = tmpArgs(1)
End If
If pth1 > "" Then
Call ListFiles(pth1, st1 & "*.*", True)
Else
Cancel = True
MsgBox "There isn't any attached file for this task."
End If
End Sub
Add the red code to see OpenArgs.
The code that opens the form must specify the openargs like this:
Docmd.Openform "frmWhatever",,,,,,"Hello"
In this case, the form_open event would see "Hello" as the openargs.
If the form is opened automatically at BOJ via the current DB settings Option, it won't have any openargs, so if you recently added that option, openargs will be null.
If you open the form via clicking in the Navigation Pane, the openargs will be null.