PC Review


Reply
Thread Tools Rate Thread

Check for duplicate with multiple criteria

 
 
mbparks
Guest
Posts: n/a
 
      23rd May 2010
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.
 
Reply With Quote
 
 
 
 
Tom van Stiphout
Guest
Posts: n/a
 
      23rd May 2010
On Sat, 22 May 2010 18:23:01 -0700, mbparks
<(E-Mail Removed)> 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.

 
Reply With Quote
 
mbparks
Guest
Posts: n/a
 
      23rd May 2010
In the current form, move the the record with the correct case number.

"Tom van Stiphout" wrote:

> On Sat, 22 May 2010 18:23:01 -0700, mbparks
> <(E-Mail Removed)> 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.

> .
>

 
Reply With Quote
 
Tom van Stiphout
Guest
Posts: n/a
 
      23rd May 2010
On Sat, 22 May 2010 22:32:01 -0700, mbparks
<(E-Mail Removed)> wrote:

I'm assuming you meant "move to the record with the correct
casenumber". This is accomplished with the bookmark technique:
with me.recordsetclone
.findfirst "[case number]=" & me.myCasenumberControlName
if not .nomatch then
me.bookmark = .bookmark
end if
end with

-Tom.
Microsoft Access MVP


>In the current form, move the the record with the correct case number.
>
>"Tom van Stiphout" wrote:
>
>> On Sat, 22 May 2010 18:23:01 -0700, mbparks
>> <(E-Mail Removed)> 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.

>> .
>>

 
Reply With Quote
 
mbparks
Guest
Posts: n/a
 
      31st May 2010
Hi Tom,
I'm still having trouble with this. In your reply you have " &
me.myCasenumberControlName". My control is a text box called Case Number.
I've entered it as "myCaseNumber" and "my [Case Number]. Neither are working.
Please help.

"Tom van Stiphout" wrote:

> On Sat, 22 May 2010 22:32:01 -0700, mbparks
> <(E-Mail Removed)> wrote:
>
> I'm assuming you meant "move to the record with the correct
> casenumber". This is accomplished with the bookmark technique:
> with me.recordsetclone
> .findfirst "[case number]=" & me.myCasenumberControlName
> if not .nomatch then
> me.bookmark = .bookmark
> end if
> end with
>
> -Tom.
> Microsoft Access MVP
>
>
> >In the current form, move the the record with the correct case number.
> >
> >"Tom van Stiphout" wrote:
> >
> >> On Sat, 22 May 2010 18:23:01 -0700, mbparks
> >> <(E-Mail Removed)> 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.
> >> .
> >>

> .
>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
multiple criteria count formula with duplicate data Excel-User-RR Microsoft Excel Worksheet Functions 10 18th Feb 2009 02:05 PM
Sum single or duplicate rows with multiple criteria =?Utf-8?B?TGlzYSBC?= Microsoft Excel Worksheet Functions 3 15th Aug 2007 08:29 AM
Identify Duplicate Items Based On Multiple Criteria calummurdo@gmail.com Microsoft Excel Worksheet Functions 8 8th Sep 2006 12:22 PM
Identify Duplicate Items Based On Multiple Criteria calummurdo@gmail.com Microsoft Excel Worksheet Functions 0 7th Sep 2006 12:01 PM
Check for duplicate records based on mulitple criteria =?Utf-8?B?SGVsbG9Xb3JsZA==?= Microsoft Access Form Coding 0 26th Mar 2006 11:47 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 08:52 PM.