Form trying to add duplicates to table

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a purchase order db. I modified a form where you can begin to type
the name of the company and all the information (address, phone, etc.) comes
up. Now, when I try to attach an order to a company, Access 2000 comes up
with an error saying it is trying to add duplicates and can't because of the
primary key. Any ideas? Help!

Thanks
 
Ummm....I'm thinking that it's because the primary key is being duplicated.
Look at what the primary key is and look at what the values are before they
are saved in the before update event.

Good Luck
Greg
 
There is not event procedure for the Before Update. I created one for the
AfterUpdate to fill in the text boxes corresponding to the company info. Is
there an expression that I should have in the before update? I just want
this form to find a company as the user types in the company name, then
attach an order to that company. I already have all the companies stored in
a table. Any ideas?

Thanks
 
Is the primary key from the Company table a foreign key in the Orders table?
Also, make sure that you have allowed duplicates in the Orders table where
appropriate. Check that table in design view to determine that.
 
The primary key is a foreign key in the Orders table and duplicates are
allowed in the Orders table. I recreated the command button that calls the
Orders form and I was able to enter an order for that specific company. The
report I created to print out all this information is no longer pulling the
correct information. I will have to see why that's happening now. Also, the
drop down box that lists all the companies goes across the whole screen even
the the text is very short. Any ideas? Thanks for your help so far!
 
Recreated the command button from where, and placed it where? Do you see the
correct information on the form, but not on the report? If so, try saving
the form as a report, then create a combo button on the form to open
(preview) the report. If it looks OK, note the record source and other
information and use the same on the report format you want to use.
You say you modified a form. Where did that form come from? I would
suggest using the combo box wizard to populate the form based on a value you
select. With the combo box Auto Expand property set to Yes you can have it
fill in values automatically, and with Limit to List set to Yes you can avoid
inaccuracies. As I recall, the After Update event for a combo box created by
the wizard for this purpose is to find the record that matches the selection.
You can view and tweak the code as needed.
For the combo box width (I assume that is what you mean by "drop-down list")
you could try specifying a width in the combo box property sheet.
For ease of viewing, is there a Customer form corresponding to the Customer
table, and an Orders subform? The table relationship you have described
suggests such an approach.
 
Back
Top