Error on Exit procedure

C

Clyde

"Syntax error.... possible missing comma.." This error msg occurs after
exiting the procedure. In debug if stepping through every line of code you
get no error until Exit Sub. So no line of code exhibits an error.
Obviously I have checked all the SQL statements, they all work, the procedure
works perfectly in all respects. How the heck do you figure this out if no
line of code causes an error?
Waiting for Ike in Houston.
 
C

Chris O'C via AccessMonster.com

If the code editor doesn't turn any line of code red when you try to compile,
you'll have to post your code so others can try to spot it.

Chris
Microsoft MVP
 
L

Linq Adams via AccessMonster.com

I've never come across this particular error message before. Access' error
messages frequently have nothing to do with the actual problem. You might
carefully check for a stray comma or period that's all by itself. I've known
code to be deleted and the developer accidentally left a stray punctuation
mark behind to cause havoc.

If you don't find anything, post your code as Chris requested.

And get everything backed up before Ike arrives!
 
C

Chris O'C via AccessMonster.com

"I think the error is in the above code."

You have many errors. Even assuming the undefined functions and constant are
defined correctly elsewhere and the word wrap in your post doesn't exist in
your module's code, the frmPopStopDun isn't going to be loaded after you've
closed the dialog window. You *have to* close the dialog window before the
next line of code in the StopDunning proc will run. Since that form isn't
open the code jumps to Exit_StopDunning with an unnecessary goto statement
(which is poor programming practice). None of the rest of your intended code
runs.

You should fix the code in this proc first. It's currently syntactically
correct (provided the missing definitions are defined correctly elsewhere) so
your syntax error exists elsewhere.

Chris
Microsoft MVP

Thanks guys. Here is the code.

Public Sub StopDunning()
'********************************************
'Date Last Modified: 08/14/08
'Purpose: Temporarily stop dunning
'Called By: MenuBar StopDun
'********************************************
On Error GoTo ErrorHandler:
Dim intDays As Integer
Dim strSQL As String, strDays As String

DoCmd.OpenForm "frmPopStopDun", , , , , acDialog
'could have canceled
If IsLoaded("frmPopStopDun") Then
If IsNull(Forms!frmPopStopDun!txtDays) Then
MsgBox "You must enter a value for days. Exiting with no
changes."
GoTo Exit_StopDunning
End If
intDays = Forms!frmPopStopDun!txtDays
DoCmd.Close acForm, "frmPopStopDun"
Else
GoTo Exit_StopDunning
End If

With Me
'save the current position and start of delay in dun tbl
strSQL = "INSERT INTO tblDunTempDelay ( CustNo, DunDate,
TempDelayStart ) " & _
"SELECT tblDun.CustNo, tblDun.DunDate, Date() AS Tstart " & _
"From tblDun " & _
"WHERE tblDun.CustNo = " & QUOTE & !CUSTNO & QUOTE & ";"

DoCmd.SetWarnings False
DoCmd.RunSQL strSQL
DoCmd.SetWarnings True

If !Dunning Then
Call DunOff(!CUSTNO)
End If

!TempDelayEnd = DateAdd("d", intDays, Date) 'DateAdd("d", intDays,
Date)
'record to notes
!Notes = !Notes & vbCrLf & Date & " Started a Temp DunDelay today,
ending " & !TempDelayEnd & " ."
'had reset some cust flds in DunOff() or added TempDelayEnd to cust
even if not in dunning
.Requery
End With

Exit_StopDunning:
Exit Sub
ErrorHandler:
basUtilities.ErrorHandler Me.Name, "StopDunning"
Resume Exit_StopDunning

End Sub

frmPopstopdun has one field, txtDays. Two cmd buttons with code to cancel
or hide.
The function DunOff is called by 2 other procedures with no error. So I
think the error is in the above code. Please note the errorhandler does not
trap this error.
"Syntax error.... possible missing comma.." This error msg occurs after
exiting the procedure. In debug if stepping through every line of code you
[quoted text clipped - 3 lines]
line of code causes an error?
Waiting for Ike in Houston.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top