Group:  Microsoft Access ยป microsoft.public.access.formscoding
Thread: Append querie error

Geek News

Append querie error
h3llz 12/7/2008 2:58:01 PM
DoCmd.RunSQL ("INSERT INTO tblProductsLog VALUES (" & [staffID] & "," &
[productID] & "," & -[productQuantity] & ",'" & Now() & "');")

staffID, productID, productQuantity are integer
RE: Append querie error
h3llz 12/7/2008 3:04:11 PM
i found the error, staffID and productID was keys and if i remove the keys it
work, but why is this? (key violations)

"h3llz" wrote:

[Quoted Text]
> DoCmd.RunSQL ("INSERT INTO tblProductsLog VALUES (" & [staffID] & "," &
> [productID] & "," & -[productQuantity] & ",'" & Now() & "');")
>
> staffID, productID, productQuantity are integer
Re: Append querie error
"Douglas J. Steele" <NOSPAM_djsteele[ at ]NOSPAM_gmail.com> 12/7/2008 5:00:05 PM
You're attempting to add a second record with the same values of staffID and
productID.

If staffID and productID are the primary key, that's not allowed. (That's
the whole point of a primary key...)

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


"h3llz" <h3llz[ at ]discussions.microsoft.com> wrote in message
news:199EB5FD-5227-4B67-A9D7-9867F63C5788[ at ]microsoft.com...
[Quoted Text]
>i found the error, staffID and productID was keys and if i remove the keys
>it
> work, but why is this? (key violations)
>
> "h3llz" wrote:
>
>> DoCmd.RunSQL ("INSERT INTO tblProductsLog VALUES (" & [staffID] & "," &
>> [productID] & "," & -[productQuantity] & ",'" & Now() & "');")
>>
>> staffID, productID, productQuantity are integer


Re: Append querie error
h3llz 12/8/2008 2:23:17 PM
The combination of basketID and productID is unique

"Douglas J. Steele" wrote:

[Quoted Text]
> You're attempting to add a second record with the same values of staffID and
> productID.
>
> If staffID and productID are the primary key, that's not allowed. (That's
> the whole point of a primary key...)
>
> --
> Doug Steele, Microsoft Access MVP
> http://I.Am/DougSteele
> (no private e-mails, please)
>
>
> "h3llz" <h3llz[ at ]discussions.microsoft.com> wrote in message
> news:199EB5FD-5227-4B67-A9D7-9867F63C5788[ at ]microsoft.com...
> >i found the error, staffID and productID was keys and if i remove the keys
> >it
> > work, but why is this? (key violations)
> >
> > "h3llz" wrote:
> >
> >> DoCmd.RunSQL ("INSERT INTO tblProductsLog VALUES (" & [staffID] & "," &
> >> [productID] & "," & -[productQuantity] & ",'" & Now() & "');")
> >>
> >> staffID, productID, productQuantity are integer
>
>
>
Re: Append querie error
"Douglas J. Steele" <NOSPAM_djsteele[ at ]NOSPAM_gmail.com> 12/8/2008 4:17:57 PM
Your INSERT statement isn't setting basketID, so it'll be Null. If the value
for productID already exists in the table with a Null basketID, that's a
duplicate.

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


"h3llz" <h3llz[ at ]discussions.microsoft.com> wrote in message
news:FDA82B0D-73E2-4048-9FAF-DD61C9D1ADDF[ at ]microsoft.com...
[Quoted Text]
> The combination of basketID and productID is unique
>
> "Douglas J. Steele" wrote:
>
>> You're attempting to add a second record with the same values of staffID
>> and
>> productID.
>>
>> If staffID and productID are the primary key, that's not allowed. (That's
>> the whole point of a primary key...)
>>
>> --
>> Doug Steele, Microsoft Access MVP
>> http://I.Am/DougSteele
>> (no private e-mails, please)
>>
>>
>> "h3llz" <h3llz[ at ]discussions.microsoft.com> wrote in message
>> news:199EB5FD-5227-4B67-A9D7-9867F63C5788[ at ]microsoft.com...
>> >i found the error, staffID and productID was keys and if i remove the
>> >keys
>> >it
>> > work, but why is this? (key violations)
>> >
>> > "h3llz" wrote:
>> >
>> >> DoCmd.RunSQL ("INSERT INTO tblProductsLog VALUES (" & [staffID] & ","
>> >> &
>> >> [productID] & "," & -[productQuantity] & ",'" & Now() & "');")
>> >>
>> >> staffID, productID, productQuantity are integer
>>
>>
>>


Home | Search | Terms | Imprint Contact
Newsgroups Reader - provided by WiredBox.Net