JumpinJimRivers
MIS
Can't I place a public procedure behind a FORM and call it from anywhere in the application? Could someone help me understand why I'm getting the error "sub or function not defined" when I try to call it from a subform.
Thanks
This is what's in the main form that I want to call from the subform:
Public Sub RequeryChangeOrderTotals()
On Error GoTo ErrorHandler
Dim db As Database
Dim Job As String
Dim Subm As String
Dim Unsubm As String
Dim ContingUnsubm As String
Dim ContingSubm As String
Dim sqlSubmitted As String
Dim sqlUnsubmitted As String
Dim rstSubmitted As Recordset
Dim rstUnsubmitted As Recordset
Job = Forms!frmChangeOrders_Module!JobID
Subm = "Forms!frmChangeOrders_Module!frmChangeOrders_Tabs!txtSubmittedTotal"
Unsubm = "Forms!frmChangeOrders_Module!frmChangeOrders_Tabs!txtUnsubmittedTotal"
ContingUnsubm = "Forms!frmChangeOrders_Module!frmChangeOrders_Tabs.form!txtSubmittedTotal"
ContingSubm = "Forms!frmChangeOrders_Module!frmChangeOrders_Tabs.form!txtUnsubmittedTotal"
sqlSubmitted = "SELECT COAmount FROM qryChangeOrders_Listbox_SubmittedChangeOrdersLog WHERE JobID='" & Job & "'"
sqlUnsubmitted = "SELECT COAmount FROM qryChangeOrders_Listbox_UnsubmittedChangeOrdersLog WHERE JobID='" & Job & "'"
If Not IsNull(Forms!frmChangeOrders_Module!JobID) Then
Set db = CurrentDb
Set rstSubmitted = db.OpenRecordset(sqlSubmitted, dbOpenForwardOnly)
Set rstUnsubmitted = db.OpenRecordset(sqlUnsubmitted, dbOpenForwardOnly)
If rstSubmitted.RecordCount <> 0 Then
Subm = rstSubmitted!COAmount
ContingSubm = rstSubmitted!COAmount
End If
If rstUnsubmitted.RecordCount <> 0 Then
Unsubm = rstUnsubmitted!COAmount
ContingUnsubm = rstUnsubmitted!COAmount
End If
rstSubmitted.Close
rstUnsubmitted.Close
db.Close
Set rstSubmitted = Nothing
Set rstUnsubmitted = Nothing
Set db = Nothing
End If
ExitHere:
Exit Sub
ErrorHandler:
rstSubmitted.Close
rstUnsubmitted.Close
db.Close
Set rstSubmitted = Nothing
Set rstUnsubmitted = Nothing
Set db = Nothing
MsgBox "An error occurred: " & Err.Description
Resume ExitHere
End Sub
And then I call it from a subform:
Private Sub Form_AfterUpdate()
RequeryChangeOrderTotals
End Sub
Thanks
This is what's in the main form that I want to call from the subform:
Public Sub RequeryChangeOrderTotals()
On Error GoTo ErrorHandler
Dim db As Database
Dim Job As String
Dim Subm As String
Dim Unsubm As String
Dim ContingUnsubm As String
Dim ContingSubm As String
Dim sqlSubmitted As String
Dim sqlUnsubmitted As String
Dim rstSubmitted As Recordset
Dim rstUnsubmitted As Recordset
Job = Forms!frmChangeOrders_Module!JobID
Subm = "Forms!frmChangeOrders_Module!frmChangeOrders_Tabs!txtSubmittedTotal"
Unsubm = "Forms!frmChangeOrders_Module!frmChangeOrders_Tabs!txtUnsubmittedTotal"
ContingUnsubm = "Forms!frmChangeOrders_Module!frmChangeOrders_Tabs.form!txtSubmittedTotal"
ContingSubm = "Forms!frmChangeOrders_Module!frmChangeOrders_Tabs.form!txtUnsubmittedTotal"
sqlSubmitted = "SELECT COAmount FROM qryChangeOrders_Listbox_SubmittedChangeOrdersLog WHERE JobID='" & Job & "'"
sqlUnsubmitted = "SELECT COAmount FROM qryChangeOrders_Listbox_UnsubmittedChangeOrdersLog WHERE JobID='" & Job & "'"
If Not IsNull(Forms!frmChangeOrders_Module!JobID) Then
Set db = CurrentDb
Set rstSubmitted = db.OpenRecordset(sqlSubmitted, dbOpenForwardOnly)
Set rstUnsubmitted = db.OpenRecordset(sqlUnsubmitted, dbOpenForwardOnly)
If rstSubmitted.RecordCount <> 0 Then
Subm = rstSubmitted!COAmount
ContingSubm = rstSubmitted!COAmount
End If
If rstUnsubmitted.RecordCount <> 0 Then
Unsubm = rstUnsubmitted!COAmount
ContingUnsubm = rstUnsubmitted!COAmount
End If
rstSubmitted.Close
rstUnsubmitted.Close
db.Close
Set rstSubmitted = Nothing
Set rstUnsubmitted = Nothing
Set db = Nothing
End If
ExitHere:
Exit Sub
ErrorHandler:
rstSubmitted.Close
rstUnsubmitted.Close
db.Close
Set rstSubmitted = Nothing
Set rstUnsubmitted = Nothing
Set db = Nothing
MsgBox "An error occurred: " & Err.Description
Resume ExitHere
End Sub
And then I call it from a subform:
Private Sub Form_AfterUpdate()
RequeryChangeOrderTotals
End Sub