Question Forms/Tables (1 Viewer)

Rogue Programme

Registered User.
Local time
Today, 09:42
Joined
Jul 16, 2003
Messages
55
Hi, I have two forms linked to one table. The 2 forms are linked to eachother. I have a button on form 1 that opens form 2. However, if i click to go on form 2 without saving what i've input in form 1 I lose the data.

My question - is there a way I can insert a piece of code in the buttons' on click event procedure to autosave the data in form 1 before it goes over to form 2?

Form 1 = 'frmclaimdetail'
Form 2 = 'frmpmtpack

Here's the code on the button that links the 2 forms together (on click event procedure):

Private Sub cmdopenpmtpack_Click()
On Error GoTo Err_cmdopenpmtpack_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "frmpmtpack"

stLinkCriteria = "[ClaimID]=" & "'" & Me![ClaimID] & "'"
DoCmd.OpenForm stDocName, , , stLinkCriteria
[Forms]![frmpmtpack]![ClaimID].SetFocus


Exit_cmdopenpmtpack_Click:
Exit Sub

Err_cmdopenpmtpack_Click:
MsgBox Err.Description
Resume Exit_cmdopenpmtpack_Click

End Sub

Also, I'm curious as to why i lose the data if it's all being stored in the same table.

Thanks
Mike
 

Brianwarnock

Retired
Local time
Today, 09:42
Joined
Jun 2, 2003
Messages
12,701
Hi Mike
I realise that all of your duplicate posts were probably created by the system acting up, but please go into them and select edit and delete the post.

Brian
 

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Today, 03:42
Joined
Feb 28, 2001
Messages
27,321
First, I agree with Brian that the forum server has probably caused a lot of duplicate posts. So when you get a chance, find the unanswered duplicates and delete them.

Second, your question includes a statement that I don't understand.

Also, I'm curious as to why i lose the data if it's all being stored in the same table.

Now I'm curious as to why you have a sub-form with a single-table recordsource. That isn't normally done. I could see something like using TAB controls to look at different parts of an unusually complex record - that doesn't count as a sub-form. But sub-forms are most often used in a parent/child table relationship, where the child drives the sub-form and the parent drives the main form. While I can't off-hand tell you why you observe the specific problem, I can suggest that you have a non-standard use of a form and I don't know WHAT Access will do in the case you describe.
 

dbDamo

Registered User.
Local time
Today, 09:42
Joined
May 15, 2009
Messages
395
Add

Code:
DoCmd.RunCommand acCmdSaveRecord

Before you end the sub
 
Local time
Today, 01:42
Joined
Feb 25, 2008
Messages
410
When the second form is opened with link criteria, then the first form is saved, will the link criteria auto update the data on form 2?
Or, in other word, would it not be best to place the save command BEFORE the OpenForm command?
I have no idea because I don't use link criteria very often.
 

dbDamo

Registered User.
Local time
Today, 09:42
Joined
May 15, 2009
Messages
395
I don't use lnk criteria often either, but I would think it should update the data on form 2.

Either way I believe you are correct in saying that the save should occur before the OpenForm command
 

Users who are viewing this thread

Top Bottom