I'm trying to move a piece of code I've tested successfully as a private sub into a public sub and am having troubles with the declaration for form.
Here is the code that worked for the private sub
Code:
Private Sub cboRockVendorID_DblClick(Cancel As Integer)
'Dim strDocName As String
'strDocName = "Receipts"
'DoCmd.OpenForm strDocName
'If Not IsNull(Me.tboMaterial) Then
'With Forms(strDocName)
' .pgMaterial.SetFocus
' End With
'End If
End Sub
Here is what I have in my public module that is not working. There is an error on my form declaration.
Code:
Public Sub SubDbl2(form)
Dim strDocName As String
Public strDocName As String
strDocName = Forms.["Receipts"]
DoCmd.OpenForm "strDocName", , , "[ID] = " & form!ID
If Not IsNull(form.tboRockProduct) Then
With Forms(strDocName)
.pgRock.SetFocus
End With
End If
If Not IsNull(form.tboMaterial) Then
With Forms(strDocName)
.pgMaterial.SetFocus
End With
End If
If Not IsNull(form.tboOutsideService) Then
With Forms(strDocName)
.pgOutsideService.SetFocus
End With
End If
If Not IsNull(form.Permit) Then
With Forms(strDocName)
.pgPermit.SetFocus
End With
End If
End Sub
How can this be changed to get it to work? I'm sure I'm missing something simple.
Thank you for looking.