View Single Post
  #2  
Old May 23rd, 2010, 05:36 AM posted to microsoft.public.access.forms
Tom van Stiphout[_2_]
external usenet poster
 
Posts: 1,653
Default Check for duplicate with multiple criteria

On Sat, 22 May 2010 18:23:01 -0700, mbparks
wrote:

I'm not sure I follow you. You write: "If it is blank I would like the
existing record to open". Open how? Do you mean "open another form
with the correct casenumber preselected", or do you mean "in the
current form, move to the record with the correct casenumber"? Or?

It is nearly impossible and not recommended to use ONE control both
for lookups as for data-entry.

-Tom.
Microsoft Access MVP


My table contains a field labled "Case Number" and another field labled "Date
Completed". I have created an input form and included code to check for
duplicate case numbers. A msgbox appears with a warning. I would like the
code to check for a duplicate case number and then check the "Date Completed"
field to see if it is blank. If it is blank I would like the existing
record to open. If the date completed field is not blank I would like to
continue entering data in the form to create a new record.
The code I am currently using is:

Private Sub Case_Number_BeforeUpdate(Cancel As Integer)
If DCount("*", "Copy of DIV 3 ICT Database", "[Case Number] = '" & Me![Case
Number] & "'") 0 Then
MsgBox "This item already exists in the table."
Cancel = True
Me.Undo
End If
End Sub

How can I incorporate the changes?
Any help is greatly appreciated.