Form/Subform problems

spalmateer

Registered User.
Local time
Today, 20:28
Joined
Dec 5, 2000
Messages
46
I'm having a problem with a subform that is based off a main customer form. My subform pulls up warranty information for the customer that is currently displayed in the main form. The problem is that whenever I enter a new customer into the main form and then go to the subform to enter warranty information, any information that I type in is not saved into the table. It disappears after leaving the subform and re-entering it. I don't have this problem for customers that are already entered into the system, just customers that I'm adding. My main form is sourced off a query and my subform is sourced off a table for warranty information.
The main customer table and the warranty table have a one to one relationship.
Also should I have allow edits turned on or off for the subform?
I have no idea what is causing the problem though it maybe something small that I'm overlooking. Any ideas? Thanks in advance for any insight or ideas.
 
As I recall, I had a similar problem a while ago and that was because I had forgotten that the new records added to a form are not saved until you either a)close the form or b)move to another record or c)specifically tell access to save the record.

The way I worked around it was, on the same button which opens the linked popup form I specifically told the form to save the record.

Essentially because the record isn't saved, there is no link to reference when the pop up is opened, and that is why the data is lost(in my case it wasn't lost, it just didn;t have the appropriate record number in the foreign link field, and so couldn't retrieve the info)

Hope that helps

Ian
 
I believe that is the problem. When I go to the popup form without moving to another record(saving) the information disappears. When I first save the record and then go to the popup form then there is no problem. I tried inserting the following line (on click) for the button that opens the popup form:

DoCmd.Save acForm, "frmCustInfMain"

This wouldn't work though. Is it the right line of code to use?

Also my popup form is related (one to one) through customer number. I don't want users to be able to enter records in the popup form so I disabled allow additions. Is this possibly causing the problems with a blank form showing up by not allowing a record to be created initially upon entering? Or is the customer number automatically created by the relationship of the table? For example- I have two tables. One is tblcustinf which holds addresses, ect , and customer number(primary key). I also have a model/serial numbers table which has a one to one relationship with tblcustinf and has customer number(primary key). When a customer number is assigned in the table tblcustinf, does it automatically assign or create the same custnumber to the second table? Sorry for the confusion! Thanks Again for the help!
Scott

[This message has been edited by spalmateer (edited 01-21-2001).]
 
Using DoCmd.Save acForm, "frmCustInfMain":

I think this only saves the form design changes and not the contents of the table(I could be wrong).The way I get round it is to build a save button - rip the code out o it and place before the open popup form code.

You need to turn allow additions on if you wnat users to be able to enter new records.

As for record number creation, think of it like this- if it's an autonumber field it will create itself for you, but that does not necessarily mean that the linked record will have the appropriate linked number.It's about data integrity - the easiest way to prove this is to make the primary and foreign fields visible during design so you can test if the desired value is being passed correctly.

Give it a try and come back if still no luck

Ian
 

Users who are viewing this thread

Back
Top Bottom