I have this code below that I am running in a form's code page:
The line in bold ( ...Execute SQL) sometimes throws the error "Catastrophic Error". Since I am set to "Break on All Errors", I just hit F8 a few times and the statement works. This error only happens randomly. All of the values are valid, as it eventually works. However I couldn't distribute the app in this condition. Any ideas?
EDIT: The reason I am executing the SQL in this fashion, and not with DoCmd.RunSQL, is because we disable the warnings with "DoCmd.Setwarning False". That also disables any error from being caught by the error handler. Using CurrentProject.Connection.Execute doesn't pop up the "Are you sure you want to Insert X records ..." warnings, but still allows ADO errors to be trapping in your error handler.
Also, the DB is SQL Server 2000 with tables linked through Access.
Code:
Private Sub UpdateConcept()
On Error GoTo ErrorTrap
Dim SQL As String
SQL = "UPDATE ConceptMaster SET "
SQL = SQL & "ConceptName = '" & Trim(Me.txtName) & "', "
SQL = SQL & "ConceptDesc = '" & Trim(Me.txtDescription) & "', "
SQL = SQL & "ProductNum = " & Me.cboProducts.Column(0) & ", "
SQL = SQL & "Headline = '" & Trim(Me.txtHeadline) & "', "
SQL = SQL & "Message = '" & Trim(Me.txtMessage) & "', "
SQL = SQL & "LegendText = '" & Trim(Me.txtLegend) & "', "
SQL = SQL & "Study = '" & Me.cboStudy & "', "
SQL = SQL & "ModifyDate = #" & Format(Now, "M/D/YYYY hh:mm:ss") & "#, "
SQL = SQL & "ModifiedBy = '" & PUserName & "' "
SQL = SQL & "WHERE ConceptNumber = " & Me.txtConceptNum & ";"
[b]CurrentProject.Connection.Execute SQL[/b]
ExitPoint:
Exit Sub
ErrorTrap:
gErrorProcedure = ERR_SOURCE & "UpdateConcept()"
DoCmd.OpenForm "GenericErrorForm"
End Sub
The line in bold ( ...Execute SQL) sometimes throws the error "Catastrophic Error". Since I am set to "Break on All Errors", I just hit F8 a few times and the statement works. This error only happens randomly. All of the values are valid, as it eventually works. However I couldn't distribute the app in this condition. Any ideas?
EDIT: The reason I am executing the SQL in this fashion, and not with DoCmd.RunSQL, is because we disable the warnings with "DoCmd.Setwarning False". That also disables any error from being caught by the error handler. Using CurrentProject.Connection.Execute doesn't pop up the "Are you sure you want to Insert X records ..." warnings, but still allows ADO errors to be trapping in your error handler.
Also, the DB is SQL Server 2000 with tables linked through Access.
Last edited: