computer purchasing - form trouble

SamDeMan

Registered User.
Local time
Today, 00:11
Joined
Aug 22, 2005
Messages
182
Hi

I am attaching the relevant portion of a database which i developed. this is the scenrio:

my computer purchaser wants to keep track of all his purchases, primarily computers.

the order form has more details that are not shown. basically, the order form has the details as assets. assets can be computers or something else (not yet determined maybe servers etc..). i have two computer description tables, one that stores a model template and one that will be get a the descriptions after the user chooses the model number. the user can then edit the description. (i did not add the description tables for other types of assets).

adding a computer by choosing a model number works fine. however, depending on where the user clicks next an error occurs. if the user clicks on another field other than model number after adding the model number an error occurs (picture attached). if the user clicks into the next entry or previous entry into the model number, the sub runs fine. whats going on??

please help.

thanks,

sam
 

Attachments

  • Copy of Computers.zip
    Copy of Computers.zip
    91.3 KB · Views: 138
  • untitled1.jpg
    untitled1.jpg
    8.7 KB · Views: 134
Last edited:
Your attached jpeg files "error message" indicates that your attempting to update a child table when no parent exists.

I didn't look at your zip file.
 
yup yup,

if you review the zip file, actually a .mdb file, you will see that the sub is after the value is entered in a field, which should trigger the autonumber to automatically update. problem is, the entire record hasn't been finished. i don't know how to work around it. if you review the attached file, i am sure you will understand my delima.

thanx,

sam
 
More specifically, the relationships between your tables require that any record in the Asset Computer Description must have a valid Asset ID from the Asset table.

So, I assume that your code is trying to create a record without setting a valid entry in the AComID field.

- g
 
only in some scenerios it doesn't create the acomID. if you click on another record then there is no problem. the error only happens when creating a new record and clicking on the other fields of that record.

in order to full understand the issue, the sub adds a record to the description table which is related to the asset talble.

i think that someone with more experience than me can find the error in the script within minutes. i am still an amature.

thanks,

sam
 
Existing records on the subform already have a record in the Asset table.

For a new record, the code is trying to create a child record (Asset Computer Decsr) before the parent record (Asset) has been saved. You need to force the Asset record to save before trying to create the child.
 
yeah,

i just couldn't get it to work. i need to run my sub at exit, and then it just didn't save. i think you pinpointed the problem, i just don't know how to get around it.

thanx again,

sam
 
the following is what i posted today on the Microsoft discussion board:

Hi

i am working on database which will keep track of all computers, servers, printers etc.. purchased. i created a table which has all the computer model numbers with all the specs as fields. i have an ordrer form which records an order. there are two subforms. one is the payments subform, which works fine. then i have an asset form (continuous). the assset form records the assetID and some other info about the asset (like location, user, IPAddress etc.)

after the model number is selected, i have a sub that runs and finds the model number in my template table, and records all the specs in a table related to the assset table. its the assset description table. if my sub finds an entry with AssetID and a different model number, it deletes the old entry and adds the new entry. i record to the asset description table using an append query. the sub is set up to work on exit from the pulldown menu of the modelnumber.

the sub works fine, however, if i click on another record (its a continuous form) or if i close the form or if i click on top portion of the form, then its fine. if i click on anotehr field of the same record, then an error message comes up that there is a parent table (AssetTbl) that is missing. how do i fix this issue? also, do you have a better way to design this database?

thanks,

sam
 
I think that your problem is associated with putting data in the subform before the parent. A OrderID (autonumber) is not generated until non-default data is inserted into the Order table.

One method is to prevent this lock or disable the subform unless or until the Order record has be created.
 
not sure how to do this. please explain.

i just reviewed this problem again, and i see that it has something to do with the fact that its a pull down menu (model number). if make my selection, and i let the sub run, sub runs fine, however, i can hit Esc and the record is not saved. if i try this with the textboxes of the other fields then the record is recorded and Esc wont do much. i know i am getting closer, but i am not there yet.

sam
 
Ok, I found a solution, however i don't know how to put it in to code. please help.

if i select my value from the pulldown menu, and select Record | Save Record on the access menu, then this error does not occur. i don't know how to write this.

i would like to add this to the modelNumber_afterChange sub, but i don't know how to do this.

sam
 
this fixed my problem:

Private Sub ModelNumber_AfterUpdate()
RunCommand acCmdSaveRecord
End Sub

thanks all,

have a great weekend.

this groups rocks!!!!!!!!!!!!

thank you all,

sam
 

Users who are viewing this thread

Back
Top Bottom