A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Using Forms
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Check for duplicate with multiple criteria



 
 
Thread Tools Display Modes
  #1  
Old May 23rd, 2010, 02:23 AM posted to microsoft.public.access.forms
mbparks
external usenet poster
 
Posts: 22
Default Check for duplicate with multiple criteria

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.
  #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.

  #3  
Old May 23rd, 2010, 06:32 AM posted to microsoft.public.access.forms
mbparks
external usenet poster
 
Posts: 22
Default Check for duplicate with multiple criteria

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
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.

.

  #4  
Old May 23rd, 2010, 07:35 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 22:32:01 -0700, mbparks
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
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.

.

  #5  
Old May 31st, 2010, 03:43 AM posted to microsoft.public.access.forms
mbparks
external usenet poster
 
Posts: 22
Default Check for duplicate with multiple criteria

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
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
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.
.

.

 




Thread Tools
Display Modes

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

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 03:59 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.