Tekime
Registered User.
- Local time
- Today, 08:45
- Joined
- Jun 26, 2003
- Messages
- 72
Is it possible to use a public function from within a private form sub? I am trying to pass a value to the function, and assign the return value to a variable.
The function is defined as such in a module:
Public Function cbStatus(chargebackId As Integer) As Integer
' Determine the current status of the chargeback specified by chargebackId
Dim cnn As ADODB.Connection
Dim rstStatus As New ADODB.Recordset
Dim strSQLStatus As String
Set cnn = CurrentProject.Connection
strSQLStatus = "SELECT tbl_Chargebacks.chargebackId, tbl_Rebuttals.rbt_isComplete, tbl_Rebuttals.rbt_trackingNumber, tbl_Chargebacks.cb_resolutionId " & _
"FROM tbl_Chargebacks INNER JOIN tbl_Rebuttals ON tbl_Chargebacks.chargebackId = tbl_Rebuttals.rbt_chargebackId " & _
"WHERE tbl_Chargebacks.chargebackId = " & chargebackId
rstStatus.Open strSQLStatus, cnn, adOpenForwardOnly
rstStatus.MoveFirst
If (Not rstStatus.EOF) Then
' Make sure we have a recordset
If (rstStatus("rbt_isComplete") = True) Then
' See if a rebuttal has been completed
If (rstStatus("rbt_trackingNumber") > 0) Then
' Check for an outgoing tracking number
If (rstStatus("cb_resolutionId") > 0) Then
' See if case has been resolved
' Case closed
cbStatus = 4
Else
' Case pending resolution
cbStatus = 3
End If
Else
' Rebuttal complete, not mailed
cbStatus = 2
End If
Else
' Case entered, rebuttal incomplete
cbStatus = 1
End If
Else
cbStatus = 0
End If
End Function
When I try to call this function from a form module it fails with "Type Mismatch". I don't think any of my variable types are mismatched, but I can't figure out what is preventing me from getting this to work.
I'm calling it like:
Dim statusCode As Integer
statusCode = cbStatus(1)
Any help would be highly appreciated, thanks!
The function is defined as such in a module:
Public Function cbStatus(chargebackId As Integer) As Integer
' Determine the current status of the chargeback specified by chargebackId
Dim cnn As ADODB.Connection
Dim rstStatus As New ADODB.Recordset
Dim strSQLStatus As String
Set cnn = CurrentProject.Connection
strSQLStatus = "SELECT tbl_Chargebacks.chargebackId, tbl_Rebuttals.rbt_isComplete, tbl_Rebuttals.rbt_trackingNumber, tbl_Chargebacks.cb_resolutionId " & _
"FROM tbl_Chargebacks INNER JOIN tbl_Rebuttals ON tbl_Chargebacks.chargebackId = tbl_Rebuttals.rbt_chargebackId " & _
"WHERE tbl_Chargebacks.chargebackId = " & chargebackId
rstStatus.Open strSQLStatus, cnn, adOpenForwardOnly
rstStatus.MoveFirst
If (Not rstStatus.EOF) Then
' Make sure we have a recordset
If (rstStatus("rbt_isComplete") = True) Then
' See if a rebuttal has been completed
If (rstStatus("rbt_trackingNumber") > 0) Then
' Check for an outgoing tracking number
If (rstStatus("cb_resolutionId") > 0) Then
' See if case has been resolved
' Case closed
cbStatus = 4
Else
' Case pending resolution
cbStatus = 3
End If
Else
' Rebuttal complete, not mailed
cbStatus = 2
End If
Else
' Case entered, rebuttal incomplete
cbStatus = 1
End If
Else
cbStatus = 0
End If
End Function
When I try to call this function from a form module it fails with "Type Mismatch". I don't think any of my variable types are mismatched, but I can't figure out what is preventing me from getting this to work.
I'm calling it like:
Dim statusCode As Integer
statusCode = cbStatus(1)
Any help would be highly appreciated, thanks!