Checking for Duplicates in Multiple Fields beforeupdate | | |
I have searched all the groups I can, and I still haven't been able to
come up the solution I need. I have the following problem.
In my form named sbfrmSpoolList, I am entering a job, spool and
revision number. My table is indexed properly to not allow
duplicates, but I would like teh user to be notified that they are
typing a duplicate via a message box, then I woulld the update of the
record to be cancelled. I have tried the DLookup, but I'm not sure
how to input it with multiple fields. I have set the the beforeupdate
event on the form, not the control. I would like to know the syntax
for checking for duplicates in the following fields txtBaseJob2,
txtSpoolNo, txtSpoolRev.
Any help would appreciated.
Thanks, JC | | | | re: Checking for Duplicates in Multiple Fields beforeupdate
Could you be clearer on what indexes you have, and what is or is not allowed
to be duplicted
Phil
<john.cole@shawgrp.comwrote in message
news:82df44bb-8381-4cda-aa6e-cfc60b226cb4@m73g2000hsh.googlegroups.com... Quote:
>I have searched all the groups I can, and I still haven't been able to
come up the solution I need. I have the following problem.
>
In my form named sbfrmSpoolList, I am entering a job, spool and
revision number. My table is indexed properly to not allow
duplicates, but I would like teh user to be notified that they are
typing a duplicate via a message box, then I woulld the update of the
record to be cancelled. I have tried the DLookup, but I'm not sure
how to input it with multiple fields. I have set the the beforeupdate
event on the form, not the control. I would like to know the syntax
for checking for duplicates in the following fields txtBaseJob2,
txtSpoolNo, txtSpoolRev.
>
Any help would appreciated.
>
Thanks, JC
| | | | re: Checking for Duplicates in Multiple Fields beforeupdate
On Oct 10, 11:08*am, john.c...@shawgrp.com wrote: Quote:
I have searched all the groups I can, and I still haven't been able to
come up the solution I need. *I have the following problem.
>
In my form named sbfrmSpoolList, I am entering a job, spool and
revision number. *My table is indexed properly to not allow
duplicates, but I would like teh user to be notified that they are
typing a duplicate via a message box, then I woulld the update of the
record to be cancelled. *I have tried the DLookup, but I'm not sure
how to input it with multiple fields. *I have set the the beforeupdate
event on the form, not the control. *I would like to know the syntax
for checking for duplicates in the following fields txtBaseJob2,
txtSpoolNo, txtSpoolRev.
>
Any help would appreciated.
>
Thanks, JC
say the table is tblSpool
and the key is spoolId
in form_beforeUpdate
strwhere = "spoolNo = " & txtSpoolNo & " and spoolId <" & txtSpoolld
if (dcount("spoolId", "tblSpool", strwhere) 0) then
msgbox "Duplicate"
end if | | | | re: Checking for Duplicates in Multiple Fields beforeupdate
On Oct 11, 12:19*am, "Phil Stanton" <p...@myfamilyname.co.ukwrote: Quote:
Could you be clearer on what indexes you have, and what is or is not allowed
to be duplicted
>
Phil
>
<john.c...@shawgrp.comwrote in message
>
news:82df44bb-8381-4cda-aa6e-cfc60b226cb4@m73g2000hsh.googlegroups.com...
>
>
> Quote:
I have searched all the groups I can, and I still haven't been able to
come up the solution I need. *I have the following problem.
> Quote:
In my form named sbfrmSpoolList, I am entering a job, spool and
revision number. *My table is indexed properly to not allow
duplicates, but I would like teh user to be notified that they are
typing a duplicate via a message box, then I woulld the update of the
record to be cancelled. *I have tried the DLookup, but I'm not sure
how to input it with multiple fields. *I have set the the beforeupdate
event on the form, not the control. *I would like to know the syntax
for checking for duplicates in the following fields txtBaseJob2,
txtSpoolNo, txtSpoolRev.
> Quote:
Any help would appreciated.
> Quote:
Thanks, JC- Hide quoted text -
>
- Show quoted text -
My apologies for the lack of clarity. I am entering a job, spool and
the spool rev level. I don't want to the combination of all three be
repeated. I have the table (tblSpoolList) formatted properly with an
index for all three fields to not allow duplicates. Instead of
receiving the standard Access message for duplicate fields, I would
like to check if a duplicate Job, Spool and Rev exist and inform the
user. The table name is tblSpoolList. The field names and database
text field names are txtBaseJob2, txtSpoolNo and txtSpoolRev
I thought teh DLookup function could do this, but as I understand it,
it only looks for duplicates in one field. Each of the three fields
have duplicates for sure, but as a group, they CANNOT duplicate.
JC | | | | re: Checking for Duplicates in Multiple Fields beforeupdate
On Oct 11, 3:29*am, john.c...@shawgrp.com wrote: Quote:
On Oct 11, 12:19*am, "Phil Stanton" <p...@myfamilyname.co.ukwrote:
>
>
>
>
> Quote:
Could you be clearer on what indexes you have, and what is or is not allowed
to be duplicted
> > Quote:
<john.c...@shawgrp.comwrote in message
> Quote:
news:82df44bb-8381-4cda-aa6e-cfc60b226cb4@m73g2000hsh.googlegroups.com....
> Quote: Quote:
>I have searched all the groups I can, and I still haven't been able to
come up the solution I need. *I have the following problem.
> Quote: Quote:
In my form named sbfrmSpoolList, I am entering a job, spool and
revision number. *My table is indexed properly to not allow
duplicates, but I would like teh user to be notified that they are
typing a duplicate via a message box, then I woulld the update of the
record to be cancelled. *I have tried the DLookup, but I'm not sure
how to input it with multiple fields. *I have set the the beforeupdate
event on the form, not the control. *I would like to know the syntax
for checking for duplicates in the following fields txtBaseJob2,
txtSpoolNo, txtSpoolRev.
> Quote: Quote:
Any help would appreciated.
> Quote: Quote:
Thanks, JC- Hide quoted text -
> Quote:
- Show quoted text -
>
My apologies for the lack of clarity. *I am entering a job, spool and
the spool rev level. *I don't want to the combination of all three be
repeated. *I have the table (tblSpoolList) formatted properly with an
index for all three fields to not allow duplicates. *Instead of
receiving the standard Access message for duplicate fields, I would
like to check if a duplicate Job, Spool and Rev exist and inform the
user. *The table name is tblSpoolList. *The field names and database
text field names are txtBaseJob2, txtSpoolNo and txtSpoolRev
>
I thought teh DLookup function could do this, but as I understand it,
it only looks for duplicates in one field. *Each of the three fields
have duplicates for sure, but as a group, they CANNOT duplicate.
>
JC- Hide quoted text -
>
- Show quoted text -
say the table is tblSpool
and the key is spoolId
in form_beforeUpdate
strwhere = "spoolNo = " & txtSpoolNo & " and " & _
"baseJob2 = " & txtBaseJob2 & " and " & _
"spoolRev = " & txtSpoolRev & " and " & _
"spoolId <" & txtSpoolld
if (dcount("spoolId", "tblSpool", strwhere) 0) then
msgbox "Duplicate"
end if
note this assumes all fields are numeric, if any field is text you
need an extra '
ie. "spoolNo = '" & txtSpoolNo & "' and " & _ | | | | re: Checking for Duplicates in Multiple Fields beforeupdate
On Oct 11, 4:40*pm, Roger <lesperan...@natpro.comwrote: Quote:
On Oct 11, 3:29*am, john.c...@shawgrp.com wrote:
>
>
>
>
> Quote:
On Oct 11, 12:19*am, "Phil Stanton" <p...@myfamilyname.co.ukwrote:
> Quote: Quote:
Could you be clearer on what indexes you have, and what is or is not allowed
to be duplicted
> > Quote: Quote:
<john.c...@shawgrp.comwrote in message
> Quote: Quote:
>news:82df44bb-8381-4cda-aa6e-cfc60b226cb4@m73g2000hsh.googlegroups.com....
> Quote: Quote:
I have searched all the groups I can, and I still haven't been able to
come up the solution I need. *I have the following problem.
> Quote: Quote:
In my form named sbfrmSpoolList, I am entering a job, spool and
revision number. *My table is indexed properly to not allow
duplicates, but I would like teh user to be notified that they are
typing a duplicate via a message box, then I woulld the update of the
record to be cancelled. *I have tried the DLookup, but I'm not sure
how to input it with multiple fields. *I have set the the beforeupdate
event on the form, not the control. *I would like to know the syntax
for checking for duplicates in the following fields txtBaseJob2,
txtSpoolNo, txtSpoolRev.
> Quote: Quote:
Any help would appreciated.
> Quote: Quote:
Thanks, JC- Hide quoted text -
> Quote: Quote:
- Show quoted text -
> Quote:
My apologies for the lack of clarity. *I am entering a job, spool and
the spool rev level. *I don't want to the combination of all three be
repeated. *I have the table (tblSpoolList) formatted properly with an
index for all three fields to not allow duplicates. *Instead of
receiving the standard Access message for duplicate fields, I would
like to check if a duplicate Job, Spool and Rev exist and inform the
user. *The table name is tblSpoolList. *The field names and database
text field names are txtBaseJob2, txtSpoolNo and txtSpoolRev
> Quote:
I thought teh DLookup function could do this, but as I understand it,
it only looks for duplicates in one field. *Each of the three fields
have duplicates for sure, but as a group, they CANNOT duplicate.
> Quote:
JC- Hide quoted text -
> Quote:
- Show quoted text -
>
say the table is tblSpool
and the key is spoolId
>
in form_beforeUpdate
>
strwhere = "spoolNo = " & txtSpoolNo & " and " & _
* * * * * * * * "baseJob2 = " & txtBaseJob2 & " and " &_
* * * * * * * * "spoolRev = " & txtSpoolRev & " and " &_
* * * * * * * * * "spoolId <" & txtSpoolld
if (dcount("spoolId", "tblSpool", strwhere) 0) then
* * msgbox "Duplicate"
end if
>
note this assumes all fields are numeric, if any field is text you
need an extra '
>
ie. "spoolNo = '" & txtSpoolNo & "' and " & _- Hide quoted text -
>
- Show quoted text -
Ok, you've lost me. They primary key for the table consists of the
ID, txtSpoolNo and txtSpoolRev fields. There is no field named
spoolid. Can you clarify what you mean that for? Here is teh code I
currently have, but its working.
Dim strWhere As String
strWhere = "spoolNo = '" & txtSpoolNo & " and " & _
"baseJob2 = '" & txtBaseJob2 & " and " & _
"spoolRev = '" & txtSpoolRev & " and " & _
"spoolId <" & txtSpoolld
If (DCount("spoolId", "tblSpoolList", strWhere) 0) Then
MsgBox "Duplicate"
End If
I'm sorry for the trouble. I'm really good in vba for Excel, but I'm
almost lost in Access. Thanks for the help.
JC | | | | re: Checking for Duplicates in Multiple Fields beforeupdate
On Oct 11, 8:03*pm, john.c...@shawgrp.com wrote: Quote:
On Oct 11, 4:40*pm, Roger <lesperan...@natpro.comwrote:
>
>
>
>
> Quote:
On Oct 11, 3:29*am, john.c...@shawgrp.com wrote:
> Quote: Quote:
On Oct 11, 12:19*am, "Phil Stanton" <p...@myfamilyname.co.ukwrote:
> Quote: Quote:
Could you be clearer on what indexes you have, and what is or is not allowed
to be duplicted
> > Quote: Quote:
<john.c...@shawgrp.comwrote in message
> Quote: Quote:
news:82df44bb-8381-4cda-aa6e-cfc60b226cb4@m73g2000hsh.googlegroups.com...
> Quote: Quote:
>I have searched all the groups I can, and I still haven't been able to
come up the solution I need. *I have the following problem.
> Quote: Quote:
In my form named sbfrmSpoolList, I am entering a job, spool and
revision number. *My table is indexed properly to not allow
duplicates, but I would like teh user to be notified that they are
typing a duplicate via a message box, then I woulld the update ofthe
record to be cancelled. *I have tried the DLookup, but I'm not sure
how to input it with multiple fields. *I have set the the beforeupdate
event on the form, not the control. *I would like to know the syntax
for checking for duplicates in the following fields txtBaseJob2,
txtSpoolNo, txtSpoolRev.
> Quote: Quote:
Any help would appreciated.
> Quote: Quote:
Thanks, JC- Hide quoted text -
> Quote: Quote:
- Show quoted text -
> Quote: Quote:
My apologies for the lack of clarity. *I am entering a job, spool and
the spool rev level. *I don't want to the combination of all three be
repeated. *I have the table (tblSpoolList) formatted properly with an
index for all three fields to not allow duplicates. *Instead of
receiving the standard Access message for duplicate fields, I would
like to check if a duplicate Job, Spool and Rev exist and inform the
user. *The table name is tblSpoolList. *The field names and database
text field names are txtBaseJob2, txtSpoolNo and txtSpoolRev
> Quote: Quote:
I thought teh DLookup function could do this, but as I understand it,
it only looks for duplicates in one field. *Each of the three fields
have duplicates for sure, but as a group, they CANNOT duplicate.
> Quote: Quote:
JC- Hide quoted text -
> Quote: Quote:
- Show quoted text -
> Quote:
say the table is tblSpool
and the key is spoolId
> Quote:
in form_beforeUpdate
> Quote:
strwhere = "spoolNo = " & txtSpoolNo & " and " & _
* * * * * * * * "baseJob2 = " & txtBaseJob2 & " and "& _
* * * * * * * * "spoolRev = " & txtSpoolRev & " and "& _
* * * * * * * * * "spoolId <" & txtSpoolld
if (dcount("spoolId", "tblSpool", strwhere) 0) then
* * msgbox "Duplicate"
end if
> Quote:
note this assumes all fields are numeric, if any field is text you
need an extra '
> Quote:
ie. "spoolNo = '" & txtSpoolNo & "' and " & _- Hide quoted text -
> Quote:
- Show quoted text -
>
Ok, you've lost me. *They primary key for the table consists of the
ID, txtSpoolNo and txtSpoolRev fields. *There is no field named
spoolid. *Can you clarify what you mean that for? *Here is teh code I
currently have, but its working.
>
Dim strWhere As String
strWhere = "spoolNo = '" & txtSpoolNo & " and " & _
* * * * * * * * "baseJob2 = '" & txtBaseJob2 & " and " & _
* * * * * * * * "spoolRev = '" & txtSpoolRev & " and " & _
* * * * * * * * "spoolId <" & txtSpoolld
If (DCount("spoolId", "tblSpoolList", strWhere) 0) Then
* * MsgBox "Duplicate"
End If
>
I'm sorry for the trouble. *I'm really good in vba for Excel, but I'm
almost lost in Access. *Thanks for the help.
>
JC- Hide quoted text -
>
- Show quoted text -
UPDATE!!!!!!
I've got teh syntax of the code correct, and it's working properly. I
have only one question left. After the message box, I would like to
stop the action to save the record. What's teh syntax for that.
Here's the code I have right now.
Dim strWhere As String
strWhere = "[txtSpoolNo] = '" & txtSpoolNo & "' and " & _
"[txtbaseJob2] = '" & BaseJob2 & "' and " & _
"[txtSpoolRev] = '" & SpoolRev & "'"
If (DCount("txtSpoolNo", "tblSpoolList", strWhere) 0) Then
MsgBox "The Spool and Rev was previously released for this
project. Check your data and try again."
End If
JC | | | | re: Checking for Duplicates in Multiple Fields beforeupdate
On Oct 11, 8:03*pm, john.c...@shawgrp.com wrote: Quote:
On Oct 11, 4:40*pm, Roger <lesperan...@natpro.comwrote:
>
>
>
>
> Quote:
On Oct 11, 3:29*am, john.c...@shawgrp.com wrote:
> Quote: Quote:
On Oct 11, 12:19*am, "Phil Stanton" <p...@myfamilyname.co.ukwrote:
> Quote: Quote:
Could you be clearer on what indexes you have, and what is or is not allowed
to be duplicted
> > Quote: Quote:
<john.c...@shawgrp.comwrote in message
> Quote: Quote:
news:82df44bb-8381-4cda-aa6e-cfc60b226cb4@m73g2000hsh.googlegroups.com...
> Quote: Quote:
>I have searched all the groups I can, and I still haven't been able to
come up the solution I need. *I have the following problem.
> Quote: Quote:
In my form named sbfrmSpoolList, I am entering a job, spool and
revision number. *My table is indexed properly to not allow
duplicates, but I would like teh user to be notified that they are
typing a duplicate via a message box, then I woulld the update ofthe
record to be cancelled. *I have tried the DLookup, but I'm not sure
how to input it with multiple fields. *I have set the the beforeupdate
event on the form, not the control. *I would like to know the syntax
for checking for duplicates in the following fields txtBaseJob2,
txtSpoolNo, txtSpoolRev.
> Quote: Quote:
Any help would appreciated.
> Quote: Quote:
Thanks, JC- Hide quoted text -
> Quote: Quote:
- Show quoted text -
> Quote: Quote:
My apologies for the lack of clarity. *I am entering a job, spool and
the spool rev level. *I don't want to the combination of all three be
repeated. *I have the table (tblSpoolList) formatted properly with an
index for all three fields to not allow duplicates. *Instead of
receiving the standard Access message for duplicate fields, I would
like to check if a duplicate Job, Spool and Rev exist and inform the
user. *The table name is tblSpoolList. *The field names and database
text field names are txtBaseJob2, txtSpoolNo and txtSpoolRev
> Quote: Quote:
I thought teh DLookup function could do this, but as I understand it,
it only looks for duplicates in one field. *Each of the three fields
have duplicates for sure, but as a group, they CANNOT duplicate.
> Quote: Quote:
JC- Hide quoted text -
> Quote: Quote:
- Show quoted text -
> Quote:
say the table is tblSpool
and the key is spoolId
> Quote:
in form_beforeUpdate
> Quote:
strwhere = "spoolNo = " & txtSpoolNo & " and " & _
* * * * * * * * "baseJob2 = " & txtBaseJob2 & " and "& _
* * * * * * * * "spoolRev = " & txtSpoolRev & " and "& _
* * * * * * * * * "spoolId <" & txtSpoolld
if (dcount("spoolId", "tblSpool", strwhere) 0) then
* * msgbox "Duplicate"
end if
> Quote:
note this assumes all fields are numeric, if any field is text you
need an extra '
> Quote:
ie. "spoolNo = '" & txtSpoolNo & "' and " & _- Hide quoted text -
> Quote:
- Show quoted text -
>
Ok, you've lost me. *They primary key for the table consists of the
ID, txtSpoolNo and txtSpoolRev fields. *There is no field named
spoolid. *Can you clarify what you mean that for? *Here is teh code I
currently have, but its working.
>
Dim strWhere As String
strWhere = "spoolNo = '" & txtSpoolNo & " and " & _
* * * * * * * * "baseJob2 = '" & txtBaseJob2 & " and " & _
* * * * * * * * "spoolRev = '" & txtSpoolRev & " and " & _
* * * * * * * * "spoolId <" & txtSpoolld
If (DCount("spoolId", "tblSpoolList", strWhere) 0) Then
* * MsgBox "Duplicate"
End If
>
I'm sorry for the trouble. *I'm really good in vba for Excel, but I'm
almost lost in Access. *Thanks for the help.
>
JC- Hide quoted text -
>
- Show quoted text -
Me.Undo
Got it.
Roger, thank you for your help.
Everything is working as it should.
Thanks again. |  | Similar Microsoft Access / VBA bytes | | | /bytes/about
We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights.
Get the best answers to your questions from over 226,366 network members.
|