unbound search field

I think the problem is the search field for the pronum thinks its trying to write to the table when in fact it is only trying to search and retrieve the pronum associated with the table. and it;s raising the error.

No. The Pronum text box and the Invoice Number combo box are both unbound. They cannot write values to any table. Something else is happening on the form while you're working in it that is changing data, and that new data does not meet the requirements defined by your application, so the record cannot be saved. Something you're doing is causing a duplicate Primary Key value, which is not allowed. That is the reason the Me.Dirty = False is highlighted in the Debug, because it cannot save the record. I didn't spend time trying to duplicate the error, but it's not because of the unbound controls. It could have something to do with the way you have your Shipment subform set up. You have it based on a query joining the Invoice table and the ShipInfo table. The only table you should need here is the ShipInfo table and you let the Master/Child link of the subform control handle the insertion of the Foreign Key (in this case txtINVOICENUM). I would correct that first then test to see if you still are getting the error. While you are testing I would temporarliy add a text box on the main form bound to the PK field of the Invoice table (idxINVOICEID) so you can see it, then carefully step through your normal actions while in the form so you can see what's happening.

I also added a refresh button to clear the fields between searchs.

This is a mistake. This is a bound form, so when you "clear the fields" (at least the way you are doing it) you are actually overwriting the data in the current record for those fields. This would be fine if all your were "clearing" were the unbound controls, but that's not what you're doing. You are overwriting data in bound controls with a zero length string (""), essentially deleting that data.
 
This makes sense! Thanks so much. I will make the corrections and post back. Thanks
 
Seems to be working with your suggestions. I'll continue further testing before I close the post. Thank you for all your help.
 
Hello, everything seems to working with one exceptions. This is an edit form not a form to add records. When the user closes the form; the next time he opens it the info from the last edit is in the fields. How can I exit and clear the fields so they wont be filled on the next load with getting errors?
Thanks
 
This is a bound form so you can't really clear the fields. You could base the form on a query, then upon opening the form your could filter it for something you know does not exist, so no records will be displayed, but you would need a way to remove the filter and display the records. This could be done in the After update event of the search controls, but you would probably also want a command button or something, so the user could view records if they want to without having to perform a search.
 
Cannot base it on a query because I am allowing memo field for dataentry if needed. I will try to set the form to allow additions and on form load event go to new record and see if this raise errors. What do you think.
Thanks
 

Users who are viewing this thread

Back
Top Bottom