Problem with multi-field primary key

Rakier

Registered User.
Local time
Today, 12:28
Joined
Mar 21, 2002
Messages
75
I'm having a similar problem to other ones that have been listed, but mine is slightly different (at leas I think so).

I have a table that uses three fields as its primary key:

dtmOrderDate
strUser
strItem

Basically, it is to make sure that the same user does not enter orders for the same item more than once a day.

I have a form where the orders are placed. There is a button to click to place the order when the form is completed. Everything works great.

However, here is where the sticky part comes in. If the user tries to place an order for the same item more than once on the same day, the order seems like it goes through fine. There is no error codes that crop up. However, only the first order for that item and user is stored in the table.

I thought that there would be an error message that would crop up if the same user tried to place the order more than once, but this is not happening. The order's not being placed, but Access isn't showing an error either.

There is error trapping on the form (generic but workable), but for some reason it is not displaying an error for this.

Any thoughts?
 
suspect your form is allowing updates to the already entered record, instead of adding a new record...

you can probably check this by setting your form properties to Allow Edits:No and Data Entry:Yes.


hth,
al
 
Form already has those properties set.

Further clarification:

User chooses an item from list on main form. Clicks button to place new order. This opens an order detail form with the item information already filled in. The user then enters the quantity needed and clicks a "Place Order" button. This button then closes the form. It's at this point that I assume I should get an error stating that the record won't be saved because its a duplicate, but I am not.

Thanks for your help.
 
Figured it out.

Basically, I had enter code to save the record before I closed the form. Then the error trapping worked.

Now everything seems to be peachy.

Thanks for your help.
 
edit - Oops i'm too slow today
glad you got it sorted... :)


i assume you mean the order detail form when you say:

Form already has those properties set.

what else happens when 'Place Order' is clicked, just the form close?

al
 

Users who are viewing this thread

Back
Top Bottom