Retrieving boolean value from popup box of an amend query

  • Thread starter Thread starter richland
  • Start date Start date
R

richland

In Access 2007, I wish to utilize the boolean value produced when the user
confirms that he does/does not want to continue with an "amend" query (by
clicking on the yes or no button).

I don't understand how to obtain that value.....in order to apply it toward
activating another subroutine after the amend query process completes.

Can anyone tell me how to retrieve that value?
 
Hi,

Is this in code? By amend, do you mean append or update? It is not
really a boolean. You have to get at it through the use of error handling.
And you have to deal with several possible responses. Use the On Error
Resume Next statement along with the Err object. Here is a sample for an
append query.

Public Sub ActionQuery()

Dim lngErrorNumber As Long
Dim strErrorDescription As String

On Error GoTo Handle_Error

' Some code

' Stop using the regular error handler
On Error Resume Next
DoCmd.OpenQuery "QueryX"
' Save the current error information for later use
lngErrorNumber = Err.Number
strErrorDescription = Err.Description
' Resume using the regular error handler
On Error GoTo Handle_Error
If lngErrorNumber = 2001 Or lngErrorNumber = 2501 Or lngErrorNumber =
3059 Then
' 2001 - User cancelled the parameter box of a query which has
parameters
' 2501 - User chose No to "You are about to run an append query..."
' 2501 - For queries without parameters: User chose No to "You are
about to append..."
' 3059 - For queries with parameters: User chose No to "You are
about to append..."

' Code when user stopped query
Else
If lngErrorNumber <> 0 Then
' Some other error; re-raise the error so the regular error
handler will take care
' of it
Err.Raise lngErrorNumber, , strErrorDescription
End If

' Code when user did not stop the query
End If

' Other code

Exit_Sub:
Exit Sub

Handle_Error:
MsgBox Err.Number & ": " & Err.Description
Resume Exit_Sub

End Sub

An update query may return some other error values so you may need to
discover those and then code for them.

Hope this helps,

Clifford Bass
 
Back
Top