22007 Multiple key index with null values
Sign Up |  Live StatsLive Stats    Articles 37,330| Comments 177,224| Members 19,409, Newest tanu sandhu| Online 469
Home Contact
 (Forgotten?): 
    Sikhism
    For best SPN experience, use Firefox Internet Browser!


                                                                   Your Banner Here!    




Click Here to Register/Sign Up Daily Hukamnama Member Blogs Downloads Website Navigation Help Fonts Tags

Multiple key index with null values

Our Donation Goal : Why Donate? : Donate Today! : Donate Anonymously (ਗੁਪਤ) : Our Family of Supporters
Goal this month: 500 USD, Received: 115 USD (23%)
Please Donate...
     
Related Topics...
Thread Thread Starter Forum Replies Last Post
Null values in data base CoachBarkerOJPW Information Technology 3 28-Jul-2006 08:35 AM
Reports - Displaying values that are not null marc Information Technology 1 28-Jul-2006 08:29 AM
Update Query for Multiple Values in Single Field kayabob Information Technology 2 28-Jul-2006 08:27 AM
Separating Multiple Values from the same date Matt Bradshaw Information Technology 1 28-Jul-2006 08:07 AM
blank values not null neeraj Information Technology 5 29-Oct-2005 12:35 PM


Tags
multiple, key, index, null, values
Reply Post New Topic In This Forum Stay Connected to Sikhism, Click Here to Register Now!
  #1 (permalink)  
Old 01-Nov-2005, 13:40 PM
bondtk's Avatar bondtk
Guest
 
Posts: n/a
   
   
Multiple key index with null values

  Donate Today!   Email to Friend  Tell a Friend   Show Printable Version  Print   Contact sikhphilosophy.net Administraion for any Suggestions, Ideas, Feedback.  Feedback  

Register to Remove Advertisements
I have already read how to create a table with multiple key index, but here's
my problem. When I attempt to create this type of index, it says the index
can't contain a null value. I certainly understand this, but in my table I
Reference:: Sikh Philosophy Network http://www.sikhphilosophy.net/information-technology/6321-multiple-key-index-with-null-values.html
have 3 fields I want as keys. Contract ID (auto number), Contract Number,
and Order Number. I really need to do the check on Contract Number and Order
Number to make sure there are no duplicate entries. However, On many
Reference:: Sikh Philosophy Network http://www.sikhphilosophy.net/showthread.php?t=6321
occassions, there is no order number associated with a contract number (it's
just a stand-alone contract) so that's where my null values come in. Is
there any work around for this or another way to check for duplicate values
check both those fields? I don't want there to be any record with the same
contract number and delivery order.


Got anything to share on This Topic? Why not share your immediate thoughts/reaction with us! Login Now! or Sign Up Today! to share your views... Gurfateh!
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 01-Nov-2005, 13:40 PM
tina's Avatar tina
Guest
 
Posts: n/a
   
   
Re: Multiple key index with null values

you can validate the data in those fields at the form level, at the point of
data entry. try using the form's BeforeUpdate event, and use a DCount()
function to check the table for existing data that matches the newly entered
Reference:: Sikh Philosophy Network http://www.sikhphilosophy.net/showthread.php?t=6321
data in the form. something along the lines of

If DCount(1, "MyTableName", "ContractNumber = " _
& Me!ContractNumber) > 0 Then
Cancel = True
MsgBox "This contract number already exists in the table."
End If

if you're not familiar with the DCount function, or with the BeforeUpdate
event, take a look at them in Help - and post back if you need further
assistance.

hth


"bondtk" wrote in message
news:6AC48DDE-7C33-45AB-9167-2E2B5FA6E68A@microsoft.com...
> I have already read how to create a table with multiple key index, but

here's
> my problem. When I attempt to create this type of index, it says the

index
> can't contain a null value. I certainly understand this, but in my table

Reference:: Sikh Philosophy Network http://www.sikhphilosophy.net/showthread.php?t=6321
I
> have 3 fields I want as keys. Contract ID (auto number), Contract Number,
> and Order Number. I really need to do the check on Contract Number and

Order
> Number to make sure there are no duplicate entries. However, On many
> occassions, there is no order number associated with a contract number

(it's
> just a stand-alone contract) so that's where my null values come in. Is
> there any work around for this or another way to check for duplicate

values
> check both those fields? I don't want there to be any record with the

same
> contract number and delivery order.



Reply With Quote
  #3 (permalink)  
Old 01-Nov-2005, 13:40 PM
david epsom dot com dot au's Avatar david epsom dot com dot au
Guest
 
Posts: n/a
   
   
Re: Multiple key index with null values

What are you trying to achieve with the multi-field
index?

To enforce the requested constraint, the Join table
should be a separate table.

If there is no Order Number, the
Order Number: Contract Number
record should be missing.

(david)




"bondtk" wrote in message
Reference:: Sikh Philosophy Network http://www.sikhphilosophy.net/showthread.php?t=6321
news:6AC48DDE-7C33-45AB-9167-2E2B5FA6E68A@microsoft.com...
>I have already read how to create a table with multiple key index, but
>here's
> my problem. When I attempt to create this type of index, it says the
> index
> can't contain a null value. I certainly understand this, but in my table
Reference:: Sikh Philosophy Network http://www.sikhphilosophy.net/showthread.php?t=6321
> I
> have 3 fields I want as keys. Contract ID (auto number), Contract Number,
> and Order Number. I really need to do the check on Contract Number and
> Order
> Number to make sure there are no duplicate entries. However, On many
> occassions, there is no order number associated with a contract number
> (it's
> just a stand-alone contract) so that's where my null values come in. Is
> there any work around for this or another way to check for duplicate
> values
> check both those fields? I don't want there to be any record with the
> same
> contract number and delivery order.



Reply With Quote
  #4 (permalink)  
Old 02-Nov-2005, 11:47 AM
bondtk's Avatar bondtk
Guest
 
Posts: n/a
   
   
Re: Multiple key index with null values

This would work for just one field, but I need to validate two fields. There
Reference:: Sikh Philosophy Network http://www.sikhphilosophy.net/showthread.php?t=6321
can only be one record containing a unique set of two fields.

Record Contract Order
1 1234 Null (OK)
Reference:: Sikh Philosophy Network http://www.sikhphilosophy.net/showthread.php?t=6321
2 1234 238 (OK)
3 5678 978 (OK)
4 1234 238 (NO - Duplicate)
5 1234 Null (NO - Duplicate)

I need to check both the contract and order number together.
"tina" wrote:

> you can validate the data in those fields at the form level, at the point of
> data entry. try using the form's BeforeUpdate event, and use a DCount()
> function to check the table for existing data that matches the newly entered
> data in the form. something along the lines of
>
> If DCount(1, "MyTableName", "ContractNumber = " _
> & Me!ContractNumber) > 0 Then
> Cancel = True
> MsgBox "This contract number already exists in the table."
> End If
>
> if you're not familiar with the DCount function, or with the BeforeUpdate
> event, take a look at them in Help - and post back if you need further
> assistance.
>
> hth
>
>
> "bondtk" wrote in message
> news:6AC48DDE-7C33-45AB-9167-2E2B5FA6E68A@microsoft.com...
> > I have already read how to create a table with multiple key index, but

> here's
> > my problem. When I attempt to create this type of index, it says the

> index
> > can't contain a null value. I certainly understand this, but in my table

> I
> > have 3 fields I want as keys. Contract ID (auto number), Contract Number,
> > and Order Number. I really need to do the check on Contract Number and

> Order
> > Number to make sure there are no duplicate entries. However, On many
> > occassions, there is no order number associated with a contract number

> (it's
> > just a stand-alone contract) so that's where my null values come in. Is
> > there any work around for this or another way to check for duplicate

> values
> > check both those fields? I don't want there to be any record with the

> same
> > contract number and delivery order.

>
>
>

Reply With Quote
  #5 (permalink)  
Old 02-Nov-2005, 11:47 AM
Douglas J Steele's Avatar Douglas J Steele
Guest
 
Posts: n/a
   
   
Re: Multiple key index with null values

If DCount("*", "MyTableName", "ContractNumber = " _
& Me!ContractNumber & " AND OrderNumber = " _
Reference:: Sikh Philosophy Network http://www.sikhphilosophy.net/showthread.php?t=6321
& Me!OrderNumber) > 0 Then
Cancel = True
MsgBox "This contract number already exists in the table."
End If


--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)


"bondtk" wrote in message
news:3702B442-36A6-46E3-8FF8-92C9800FE87F@microsoft.com...
> This would work for just one field, but I need to validate two fields.

There
> can only be one record containing a unique set of two fields.
>
> Record Contract Order
> 1 1234 Null (OK)
> 2 1234 238 (OK)
> 3 5678 978 (OK)
> 4 1234 238 (NO - Duplicate)
> 5 1234 Null (NO - Duplicate)
>
> I need to check both the contract and order number together.
> "tina" wrote:
>
> > you can validate the data in those fields at the form level, at the

point of
> > data entry. try using the form's BeforeUpdate event, and use a DCount()
> > function to check the table for existing data that matches the newly

entered
> > data in the form. something along the lines of
> >
> > If DCount(1, "MyTableName", "ContractNumber = " _
> > & Me!ContractNumber) > 0 Then
> > Cancel = True
> > MsgBox "This contract number already exists in the table."
> > End If
> >
> > if you're not familiar with the DCount function, or with the

BeforeUpdate
> > event, take a look at them in Help - and post back if you need further
> > assistance.
> >
> > hth
> >
> >
> > "bondtk" wrote in message
> > news:6AC48DDE-7C33-45AB-9167-2E2B5FA6E68A@microsoft.com...
> > > I have already read how to create a table with multiple key index, but

> > here's
> > > my problem. When I attempt to create this type of index, it says the

> > index
> > > can't contain a null value. I certainly understand this, but in my

table
> > I
> > > have 3 fields I want as keys. Contract ID (auto number), Contract

Number,
> > > and Order Number. I really need to do the check on Contract Number

and
> > Order
> > > Number to make sure there are no duplicate entries. However, On many
> > > occassions, there is no order number associated with a contract number

> > (it's
> > > just a stand-alone contract) so that's where my null values come in.

Is
> > > there any work around for this or another way to check for duplicate

> > values
Reference:: Sikh Philosophy Network http://www.sikhphilosophy.net/showthread.php?t=6321
> > > check both those fields? I don't want there to be any record with the

> > same
> > > contract number and delivery order.

> >
> >
> >



Reply With Quote
  #6 (permalink)  
Old 03-Nov-2005, 11:35 AM
bondtk's Avatar bondtk
Guest
 
Posts: n/a
   
   
Re: Multiple key index with null values

Doug,

Here's what I put in the code (After update on the contract number field)
and I'm getting a syntax 3075 error (missing operator in query expression
'[Contract Number]=W25G1V AND [Order Number]='.:

If DCount("*", "Contract Order Table", "[Contract Number] = " _
& Me![Contract Number] & " AND [Order Number] = " _
& Me![Order Number]) > 0 Then
Cancel = True
MsgBox "This contract number already exists in the table."
End If

Any ideas what I'm doing. I should also say that there was no order number
in this particular record required.

"Douglas J Steele" wrote:

> If DCount("*", "MyTableName", "ContractNumber = " _
> & Me!ContractNumber & " AND OrderNumber = " _
Reference:: Sikh Philosophy Network http://www.sikhphilosophy.net/showthread.php?t=6321
> & Me!OrderNumber) > 0 Then
> Cancel = True
> MsgBox "This contract number already exists in the table."
> End If
>
>
> --
> Doug Steele, Microsoft Access MVP
> http://I.Am/DougSteele
> (no e-mails, please!)
>
>
> "bondtk" wrote in message
> news:3702B442-36A6-46E3-8FF8-92C9800FE87F@microsoft.com...
> > This would work for just one field, but I need to validate two fields.

> There
> > can only be one record containing a unique set of two fields.
> >
> > Record Contract Order
> > 1 1234 Null (OK)
> > 2 1234 238 (OK)
> > 3 5678 978 (OK)
> > 4 1234 238 (NO - Duplicate)
> > 5 1234 Null (NO - Duplicate)
> >
> > I need to check both the contract and order number together.
> > "tina" wrote:
> >
> > > you can validate the data in those fields at the form level, at the

> point of
> > > data entry. try using the form's BeforeUpdate event, and use a DCount()
> > > function to check the table for existing data that matches the newly

> entered
> > > data in the form. something along the lines of
> > >
> > > If DCount(1, "MyTableName", "ContractNumber = " _
> > > & Me!ContractNumber) > 0 Then
> > > Cancel = True
> > > MsgBox "This contract number already exists in the table."
> > > End If
> > >
> > > if you're not familiar with the DCount function, or with the

> BeforeUpdate
> > > event, take a look at them in Help - and post back if you need further
> > > assistance.
> > >
> > > hth
> > >
> > >
> > > "bondtk" wrote in message
Reference:: Sikh Philosophy Network http://www.sikhphilosophy.net/showthread.php?t=6321
> > > news:6AC48DDE-7C33-45AB-9167-2E2B5FA6E68A@microsoft.com...
> > > > I have already read how to create a table with multiple key index, but
> > > here's
> > > > my problem. When I attempt to create this type of index, it says the
> > > index
> > > > can't contain a null value. I certainly understand this, but in my

> table
> > > I
> > > > have 3 fields I want as keys. Contract ID (auto number), Contract

> Number,
> > > > and Order Number. I really need to do the check on Contract Number

> and
> > > Order
> > > > Number to make sure there are no duplicate entries. However, On many
> > > > occassions, there is no order number associated with a contract number
> > > (it's
> > > > just a stand-alone contract) so that's where my null values come in.

> Is
> > > > there any work around for this or another way to check for duplicate
> > > values
> > > > check both those fields? I don't want there to be any record with the
> > > same
> > > > contract number and delivery order.
> > >
> > >
> > >

>
>
>

Reply With Quote
  #7 (permalink)  
Old 03-Nov-2005, 11:35 AM
Douglas J Steele's Avatar Douglas J Steele
Guest
 
Posts: n/a
   
   
Re: Multiple key index with null values

Since Contract Number is a text field, as opposed to a numeric one, you need
Reference:: Sikh Philosophy Network http://www.sikhphilosophy.net/showthread.php?t=6321
to enclose the value in quotes:

If DCount("*", "Contract Order Table", "[Contract Number] = '" _
& Me![Contract Number] & "' AND [Order Number] = " _
& Me![Order Number]) > 0 Then
Cancel = True
MsgBox "This contract number already exists in the table."
End If

If Order Number is also a text field, you'll need to do the same with it:

If DCount("*", "Contract Order Table", "[Contract Number] = '" _
& Me![Contract Number] & "' AND [Order Number] = '" _
& Me![Order Number] & "'") > 0 Then
Cancel = True
MsgBox "This contract number already exists in the table."
End If

Exagerated for clarity, that's

If DCount("*", "Contract Order Table", "[Contract Number] = ' " _
& Me![Contract Number] & " ' AND [Order Number] = ' " _
& Me![Order Number] & " ' ") > 0 Then
Cancel = True
MsgBox "This contract number already exists in the table."
End If


--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)


"bondtk" wrote in message
news:1113F4DA-FDA5-4C1C-A7CA-FA6A91F65D2E@microsoft.com...
> Doug,
>
> Here's what I put in the code (After update on the contract number field)
> and I'm getting a syntax 3075 error (missing operator in query expression
> '[Contract Number]=W25G1V AND [Order Number]='.:
>
> If DCount("*", "Contract Order Table", "[Contract Number] = " _
> & Me![Contract Number] & " AND [Order Number] = " _
> & Me![Order Number]) > 0 Then
> Cancel = True
> MsgBox "This contract number already exists in the table."
> End If
>
> Any ideas what I'm doing. I should also say that there was no order

number
> in this particular record required.
>
> "Douglas J Steele" wrote:
>
> > If DCount("*", "MyTableName", "ContractNumber = " _
> > & Me!ContractNumber & " AND OrderNumber = " _
> > & Me!OrderNumber) > 0 Then
> > Cancel = True
> > MsgBox "This contract number already exists in the table."
> > End If
> >
> >
> > --
> > Doug Steele, Microsoft Access MVP
> > http://I.Am/DougSteele
> > (no e-mails, please!)
> >
> >
> > "bondtk" wrote in message
> > news:3702B442-36A6-46E3-8FF8-92C9800FE87F@microsoft.com...
> > > This would work for just one field, but I need to validate two fields.

Reference:: Sikh Philosophy Network http://www.sikhphilosophy.net/showthread.php?t=6321
> > There
> > > can only be one record containing a unique set of two fields.
> > >
> > > Record Contract Order
> > > 1 1234 Null (OK)
> > > 2 1234 238 (OK)
> > > 3 5678 978 (OK)
> > > 4 1234 238 (NO - Duplicate)
> > > 5 1234 Null (NO - Duplicate)
> > >
> > > I need to check both the contract and order number together.
> > > "tina" wrote:
> > >
> > > > you can validate the data in those fields at the form level, at the

> > point of
> > > > data entry. try using the form's BeforeUpdate event, and use a

DCount()
> > > > function to check the table for existing data that matches the newly

> > entered
> > > > data in the form. something along the lines of
> > > >
> > > > If DCount(1, "MyTableName", "ContractNumber = " _
> > > > & Me!ContractNumber) > 0 Then
> > > > Cancel = True
> > > > MsgBox "This contract number already exists in the table."
> > > > End If
> > > >
> > > > if you're not familiar with the DCount function, or with the

> > BeforeUpdate
> > > > event, take a look at them in Help - and post back if you need

further
> > > > assistance.
> > > >
> > > > hth
> > > >
> > > >
> > > > "bondtk" wrote in message
> > > > news:6AC48DDE-7C33-45AB-9167-2E2B5FA6E68A@microsoft.com...
> > > > > I have already read how to create a table with multiple key index,

but
> > > > here's
> > > > > my problem. When I attempt to create this type of index, it says

the
> > > > index
> > > > > can't contain a null value. I certainly understand this, but in

my
> > table
> > > > I
> > > > > have 3 fields I want as keys. Contract ID (auto number), Contract

> > Number,
> > > > > and Order Number. I really need to do the check on Contract

Number
> > and
> > > > Order
> > > > > Number to make sure there are no duplicate entries. However, On

many
> > > > > occassions, there is no order number associated with a contract

number
> > > > (it's
> > > > > just a stand-alone contract) so that's where my null values come

in.
> > Is
> > > > > there any work around for this or another way to check for

duplicate
> > > > values
> > > > > check both those fields? I don't want there to be any record with

the
> > > > same
> > > > > contract number and delivery order.
> > > >
> > > >
> > > >

> >
> >
> >



Reply With Quote
  #8 (permalink)  
Old 03-Nov-2005, 11:35 AM
bondtk's Avatar bondtk
Guest
 
Posts: n/a
   
   
Re: Multiple key index with null values

The error is now gone (so I assume it is doing some kind of checking, but it
does not pop up when I knowingly put in a duplicate contract/order number.
Any guesses why not?

"Douglas J Steele" wrote:

> Since Contract Number is a text field, as opposed to a numeric one, you need
Reference:: Sikh Philosophy Network http://www.sikhphilosophy.net/showthread.php?t=6321
> to enclose the value in quotes:
>
> If DCount("*", "Contract Order Table", "[Contract Number] = '" _
> & Me![Contract Number] & "' AND [Order Number] = " _
> & Me![Order Number]) > 0 Then
Reference:: Sikh Philosophy Network http://www.sikhphilosophy.net/showthread.php?t=6321
> Cancel = True
> MsgBox "This contract number already exists in the table."
> End If
>
> If Order Number is also a text field, you'll need to do the same with it:
>
> If DCount("*", "Contract Order Table", "[Contract Number] = '" _
> & Me![Contract Number] & "' AND [Order Number] = '" _
> & Me![Order Number] & "'") > 0 Then
> Cancel = True
> MsgBox "This contract number already exists in the table."
> End If
>
> Exagerated for clarity, that's
>
> If DCount("*", "Contract Order Table", "[Contract Number] = ' " _
> & Me![Contract Number] & " ' AND [Order Number] = ' " _
> & Me![Order Number] & " ' ") > 0 Then
> Cancel = True
> MsgBox "This contract number already exists in the table."
> End If
>
>
> --
> Doug Steele, Microsoft Access MVP
> http://I.Am/DougSteele
> (no e-mails, please!)
>
>
> "bondtk" wrote in message
> news:1113F4DA-FDA5-4C1C-A7CA-FA6A91F65D2E@microsoft.com...
> > Doug,
> >
> > Here's what I put in the code (After update on the contract number field)
> > and I'm getting a syntax 3075 error (missing operator in query expression
> > '[Contract Number]=W25G1V AND [Order Number]='.:
> >
> > If DCount("*", "Contract Order Table", "[Contract Number] = " _
> > & Me![Contract Number] & " AND [Order Number] = " _
> > & Me![Order Number]) > 0 Then
> > Cancel = True
> > MsgBox "This contract number already exists in the table."
> > End If
> >
> > Any ideas what I'm doing. I should also say that there was no order

> number
> > in this particular record required.
> >
> > "Douglas J Steele" wrote:
> >
> > > If DCount("*", "MyTableName", "ContractNumber = " _
> > > & Me!ContractNumber & " AND OrderNumber = " _
> > > & Me!OrderNumber) > 0 Then
> > > Cancel = True
> > > MsgBox "This contract number already exists in the table."
> > > End If
> > >
> > >
> > > --
> > > Doug Steele, Microsoft Access MVP
> > > http://I.Am/DougSteele
> > > (no e-mails, please!)
> > >
> > >
> > > "bondtk" wrote in message
> > > news:3702B442-36A6-46E3-8FF8-92C9800FE87F@microsoft.com...
> > > > This would work for just one field, but I need to validate two fields.
> > > There
> > > > can only be one record containing a unique set of two fields.
> > > >
> > > > Record Contract Order
> > > > 1 1234 Null (OK)
> > > > 2 1234 238 (OK)
> > > > 3 5678 978 (OK)
> > > > 4 1234 238 (NO - Duplicate)
> > > > 5 1234 Null (NO - Duplicate)
> > > >
> > > > I need to check both the contract and order number together.
> > > > "tina" wrote:
> > > >
> > > > > you can validate the data in those fields at the form level, at the
> > > point of
> > > > > data entry. try using the form's BeforeUpdate event, and use a

> DCount()
> > > > > function to check the table for existing data that matches the newly
> > > entered
> > > > > data in the form. something along the lines of
> > > > >
> > > > > If DCount(1, "MyTableName", "ContractNumber = " _
> > > > > & Me!ContractNumber) > 0 Then
> > > > > Cancel = True
> > > > > MsgBox "This contract number already exists in the table."
> > > > > End If
> > > > >
> > > > > if you're not familiar with the DCount function, or with the
> > > BeforeUpdate
> > > > > event, take a look at them in Help - and post back if you need

> further
> > > > > assistance.
> > > > >
> > > > > hth
> > > > >
> > > > >
> > > > > "bondtk" wrote in message
> > > > > news:6AC48DDE-7C33-45AB-9167-2E2B5FA6E68A@microsoft.com...
> > > > > > I have already read how to create a table with multiple key index,

> but
> > > > > here's
> > > > > > my problem. When I attempt to create this type of index, it says

> the
> > > > > index
> > > > > > can't contain a null value. I certainly understand this, but in

> my
> > > table
> > > > > I
> > > > > > have 3 fields I want as keys. Contract ID (auto number), Contract
> > > Number,
> > > > > > and Order Number. I really need to do the check on Contract

> Number
> > > and
> > > > > Order
> > > > > > Number to make sure there are no duplicate entries. However, On

> many
> > > > > > occassions, there is no order number associated with a contract

> number
> > > > > (it's
> > > > > > just a stand-alone contract) so that's where my null values come

> in.
> > > Is
> > > > > > there any work around for this or another way to check for

> duplicate
> > > > > values
> > > > > > check both those fields? I don't want there to be any record with

> the
> > > > > same
> > > > > > contract number and delivery order.
> > > > >
> > > > >
> > > > >
> > >
> > >
> > >

>
>
>

Reply With Quote
  #9 (permalink)  
Old 03-Nov-2005, 11:35 AM
Douglas J Steele's Avatar Douglas J Steele
Guest
 
Posts: n/a
   
   
Re: Multiple key index with null values

  Donate Today!  
What happens if you go to the Debug window (Ctrl-G) and type:

?DCount("*", "Contract Order Table", "[Contract Number] = 'xxxx' AND [Order
Number] = n)

where you replace xxxx and n with values that you know should raise a
duplicate?

You could also try putting square brackets around your table name, since
you've got embedded spaces in it:

DCount("*", "[Contract Order Table]", "[Contract Number] = ...


--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)


"bondtk" wrote in message
Reference:: Sikh Philosophy Network http://www.sikhphilosophy.net/showthread.php?t=6321
news1725744-8F61-4761-A4C0-B9C1E1897117@microsoft.com...
> The error is now gone (so I assume it is doing some kind of checking, but

it
> does not pop up when I knowingly put in a duplicate contract/order number.
> Any guesses why not?
>
> "Douglas J Steele" wrote:
>
> > Since Contract Number is a text field, as opposed to a numeric one, you

Reference:: Sikh Philosophy Network http://www.sikhphilosophy.net/showthread.php?t=6321
need
> > to enclose the value in quotes:
> >
> > If DCount("*", "Contract Order Table", "[Contract Number] = '" _
> > & Me![Contract Number] & "' AND [Order Number] = " _
> > & Me![Order Number]) > 0 Then
> > Cancel = True
> > MsgBox "This contract number already exists in the table."
> > End If
> >
> > If Order Number is also a text field, you'll need to do the same with

it:
> >
> > If DCount("*", "Contract Order Table", "[Contract Number] = '" _
> > & Me![Contract Number] & "' AND [Order Number] = '" _
> > & Me![Order Number] & "'") > 0 Then
> > Cancel = True
> > MsgBox "This contract number already exists in the table."
> > End If
> >
> > Exagerated for clarity, that's
> >
> > If DCount("*", "Contract Order Table", "[Contract Number] = ' " _
> > & Me![Contract Number] & " ' AND [Order Number] = ' " _
> > & Me![Order Number] & " ' ") > 0 Then
> > Cancel = True
> > MsgBox "This contract number already exists in the table."
> > End If
> >
> >
> > --
> > Doug Steele, Microsoft Access MVP
> > http://I.Am/DougSteele
> > (no e-mails, please!)
> >
> >
> > "bondtk" wrote in message
> > news:1113F4DA-FDA5-4C1C-A7CA-FA6A91F65D2E@microsoft.com...
> > > Doug,
> > >
> > > Here's what I put in the code (After update on the contract number

field)
> > > and I'm getting a syntax 3075 error (missing operator in query

expression
> > > '[Contract Number]=W25G1V AND [Order Number]='.:
> > >
> > > If DCount("*", "Contract Order Table", "[Contract Number] = " _
> > > & Me![Contract Number] & " AND [Order Number] = " _
> > > & Me![Order Number]) > 0 Then
> > > Cancel = True
> > > MsgBox "This contract number already exists in the table."
> > > End If
> > >
> > > Any ideas what I'm doing. I should also say that there was no order

> > number
> > > in this particular record required.
> > >
> > > "Douglas J Steele" wrote:
> > >
> > > > If DCount("*", "MyTableName", "ContractNumber = " _
> > > > & Me!ContractNumber & " AND OrderNumber = " _
> > > > & Me!OrderNumber) > 0 Then
> > > > Cancel = True
> > > > MsgBox "This contract number already exists in the table."
> > > > End If
> > > >
> > > >
> > > > --
> > > > Doug Steele, Microsoft Access MVP
> > > > http://I.Am/DougSteele
> > > > (no e-mails, please!)
> > > >
> > > >
> > > > "bondtk" wrote in message
> > > > news:3702B442-36A6-46E3-8FF8-92C9800FE87F@microsoft.com...
> > > > > This would work for just one field, but I need to validate two

fields.
> > > > There
> > > > > can only be one record containing a unique set of two fields.
> > > > >
> > > > > Record Contract Order
> > > > > 1 1234 Null (OK)
> > > > > 2 1234 238 (OK)
> > > > > 3 5678 978 (OK)
> > > > > 4 1234 238 (NO - Duplicate)
> > > > > 5 1234 Null (NO - Duplicate)
> > > > >
> > > > > I need to check both the contract and order number together.
> > > > > "tina" wrote:
> > > > >
> > > > > > you can validate the data in those fields at the form level, at

the
> > > > point of
> > > > > > data entry. try using the form's BeforeUpdate event, and use a

> > DCount()
> > > > > > function to check the table for existing data that matches the

newly
> > > > entered
> > > > > > data in the form. something along the lines of
> > > > > >
> > > > > > If DCount(1, "MyTableName", "ContractNumber = " _
> > > > > > & Me!ContractNumber) > 0 Then
> > > > > > Cancel = True
> > > > > > MsgBox "This contract number already exists in the

table."
> > > > > > End If
> > > > > >
> > > > > > if you're not familiar with the DCount function, or with the
> > > > BeforeUpdate
> > > > > > event, take a look at them in Help - and post back if you need

> > further
> > > > > > assistance.
> > > > > >
> > > > > > hth
> > > > > >
> > > > > >
> > > > > > "bondtk" wrote in message
> > > > > > news:6AC48DDE-7C33-45AB-9167-2E2B5FA6E68A@microsoft.com...
> > > > > > > I have already read how to create a table with multiple key

index,
> > but
> > > > > > here's
> > > > > > > my problem. When I attempt to create this type of index, it

says
> > the
> > > > > > index
> > > > > > > can't contain a null value. I certainly understand this, but

in
> > my
> > > > table
> > > > > > I
> > > > > > > have 3 fields I want as keys. Contract ID (auto number),

Contract
> > > > Number,
> > > > > > > and Order Number. I really need to do the check on Contract

> > Number
> > > > and
> > > > > > Order
> > > > > > > Number to make sure there are no duplicate entries. However,

On
> > many
> > > > > > > occassions, there is no order number associated with a

contract
> > number
> > > > > > (it's
> > > > > > > just a stand-alone contract) so that's where my null values

come
> > in.
> > > > Is
> > > > > > > there any work around for this or another way to check for

> > duplicate
> > > > > > values
> > > > > > > check both those fields? I don't want there to be any record

with
> > the
> > > > > > same
> > > > > > > contract number and delivery order.
> > > > > >
> > > > > >
> > > > > >
> > > >
> > > >
> > > >

> >
> >
> >



Reply With Quote
   Click Here to Donate Now!

Support Us!
Become a Promoter!
Gurfateh ji, you can become a SPN Promoter by Donating as little as $10 each month. With limited resources & high operational costs, your donations make it possible for us to deliver a quality website and spread the teachings of the Sri Guru Granth Sahib Ji, to serve & uplift humanity. Every contribution counts. Donate Generously. Gurfateh!
ReplyPost New Topic In This Forum Stay Connected to Sikhism, Click Here to Register Now!

Bookmarks


(View-All Members who have read this thread : 0
There are no names to display.

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Tools Search
Search:

Advanced Search
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

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

» Active Discussions
Losing My Religion: Why...
Today 22:18 PM
12 Replies, 267 Views
Request for assistance...
Today 21:53 PM
5 Replies, 40 Views
Man Driving Without...
Today 21:09 PM
1 Replies, 45 Views
Keeping Amrit Vela
Today 21:08 PM
9 Replies, 831 Views
Do you believe in...
Today 18:11 PM
188 Replies, 3,966 Views
Panjabi
By Ishna
Today 17:56 PM
12 Replies, 259 Views
Parkash Guru Amar Das ji...
Today 17:07 PM
3 Replies, 30 Views
Serious challenges to...
Today 16:49 PM
0 Replies, 42 Views
Sikh man fights for his...
Today 16:46 PM
0 Replies, 51 Views
Sikhs Rights Group to...
Today 16:44 PM
0 Replies, 33 Views
Haryana Sikh body bans...
Today 16:39 PM
0 Replies, 34 Views
How does Sikhi help you...
Today 15:00 PM
21 Replies, 865 Views
Health Exercise And...
Today 13:30 PM
0 Replies, 55 Views
SSGS with English...
Today 12:55 PM
9 Replies, 117 Views
Rozana Reports (ਪੰਜਾਬੀ...
Today 01:44 AM
310 Replies, 7,554 Views
» Books You Should Read...
Powered by vBadvanced CMPS v3.2.3
All times are GMT +6.5. The time now is 22:35 PM.
Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2013, vBulletin Solutions, Inc.
Search Engine Optimization by vBSEO 3.6.0 PL2 Copyright © 2004-12, All Rights Reserved. Sikh Philosophy Network


Page generated in 2.69198 seconds with 32 queries
0