Error 2001

G

Guest

I have a form that has a button on it called Add New Record. It allows the
users to add a new record. However, before they can add a new record I have
some filters in the form before the update takes place. These certain fields
have to be satified before adding a new record. When one of my fields were
not satisfied, it gave me an error 2001 (you canceled the previous
operation). What am I doing wrong? Also, in my Private Sub_Form
BeforeUpdate, it is not honoring my last filter(I added *'s in front of it).
Before, I added the New Record button,when I didn't enter an issue date, it
still was proceeding to the next screen. Is something wrong with my
conditional statements? Thanks in advance for you comments.

'Add New Record
Private Sub Add_New_Record_Click()
If Me.Dirty Then
Me.Dirty = False
End If
If Not Me.NewRecord Then
RunCommand acCmdRecordsGoToNew
End If
End Sub
-----------------------------------------------------------------------------------------------
Private Sub Form_BeforeUpdate(Cancel As Integer)
Dim ingBigNum As Long
Dim mydate As Date
Dim edit As Integer

mydate = DateAdd("d", 0, Date)
response = MsgBox("Is the File ID correct " & Me.File_ID & " ?", vbYesNo,
"Verification Requested!")
If response = vbNo Then
DoCmd.CancelEvent
DoCmd.GoToControl "File ID"
answer = MsgBox("Please correct the File ID!", vbOKOnly, "Recheck")


ElseIf Me.Filing_Date <= Me.Issue_Date Then
DoCmd.CancelEvent
DoCmd.GoToControl "Issue Date"
retvalue = MsgBox("Issue Date needs to be less than the Filing Date.",
vbCritical, "Required")


ElseIf IsNull(Me.Division) = True Then
DoCmd.CancelEvent
DoCmd.GoToControl "Division"
retvalue = MsgBox("A Division must be entered.", vbCritical, "Required")

ElseIf IsNull(Me.File_ID) = True Then
DoCmd.CancelEvent
DoCmd.GoToControl "File ID"
retvalue = MsgBox("A File ID must be entered.", vbInformation, "Information")


ElseIf Not (Left(Me.File_ID, 2) = "BR" Or Left(Me.File_ID, 2) = "PK") Then
DoCmd.CancelEvent
DoCmd.GoToControl "File ID"
retvalue = MsgBox("The File ID must start with BR/PK.", vbCritical,
"Required")


ElseIf IsNull(Me.Filing_Date) = True Then
DoCmd.CancelEvent
DoCmd.GoToControl "Filing Date"
retvalue = MsgBox("A Filing Date must be entered(Ex. 02/06/06).",
vbCritical, "Required")

***ElseIf IsNull(Me.Issue_Date) = True Then
***DoCmd.CancelEvent
***DoCmd.GoToControl "Issue Date"
***retvalue = MsgBox("An Issue Date needs to be entered(Ex. 02/06/2006).",
***vbInformation, "Information")
End If
End Sub
 

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

Similar Threads

Error 2001 message 1
Error 2001 1
VBA error using Access 5
Validation Rule and Now() function 6
Password Protect form 1
Option Explicit 2
Compile Error Help 6
OpenReport Where Condition with date range 6

Top