Results 1 to 2 of 2
2002-04-05, 16:48 #1
- Join Date
- Aug 2001
- Thanked 0 Times in 0 Posts
Saving records sooner (Access 2k)
I have a centralized form (Form A) that opens all forms that are related to it.
I set the relationship to cascade "updates" and "deletes" so there aren't any "orphan" records in the related forms. I want to keep that.
I used the wizard to create command buttons to open --Form B-- and search for a corresponding record. I added addtional code to collect information from --Form A-- and insert it into --Form B--. This part works fine.
Here's the problem:
When A NEW RECORD is added to --Form A-- and the user is ready to move on to --Form B-- it opens up and everything is fine until they try to exit. At that time an error message comes up saying that you can't save the data in --Form B-- because there is no record in --Form A--, (which does remain open when working with Form B and I would like to keep it open)
The problem seems to be that the data in --Form A --record isn't being saved to the underlying table so that the subsequently used forms can read it.
I THINK I'M LOOKING FOR A WAY TO TELL --FORM A-- TO SAVE IT'S DATA TO THE UNDERLYING TABLE SO THAT THE SUBSEQUENT FORMS CAN READ/RECOGNIZE IT.
I am new to VBA and trying very hard to learn. Is there some code I can add to the form that will tell the system to save this information to the table. I am using a tab control and the command buttons are on a separate page. By the time the user goes to that page all the data they added should be saved. This tab would be a nice invisible place to put the code. When the user presses this tab the event would be ON CLICK and the save code would kick in. Then when they press the command button to open --Form B-- the data would already be saved.
Can you help me?
2002-04-06, 01:06 #2
- Join Date
- Dec 2000
- Sacramento, California, USA
- Thanked 1 Time in 1 Post
Re: Saving records sooner (Access 2k)
If you move from one form or subform to another, the current record is saved automatically. It's a little hard to tell what you're doing from the description, but I suspect that when you add a new record Form B, you need a link for the table behind Form A, in other words, a foreign key. This is probably a required field in the table behind Form B, and so it won't save its record until you supply the appropriate value. Cascading updates don't apply in this case because you don't have a link to the related table until you insert the foreign key. You need to tell Form B to get its required foreign key from your parent form or from another subform.Charlotte