A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » New Users
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

save record in continuous subform before opening child form



 
 
Thread Tools Display Modes
  #1  
Old September 5th, 2006, 02:56 PM posted to microsoft.public.access.gettingstarted
Amanda Byrne
external usenet poster
 
Posts: 29
Default save record in continuous subform before opening child form

I have a Household form that has a continuous subform for all the People that
reside in that household. The continuous subform has a command button that
opens a "child"form where the user can add additional details for that person
(add to their history, etc.)

This works well except when a new person is added to continuous subform,
when the command button is selected, the data added to the continuous subform
has not been added to the database, and is not available for the child form.
This can be avoided by clicking on a different record in the subform prior to
opening the child form, but for ease of use, is there some code I could add
to the command button that would save the current record so that the child
form opens properly?

Code on the command button:
Private Sub Command_Details_Click()
On Error GoTo Err_Command_Details_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "People"

stLinkCriteria = "[People.People ID]=" & Me![People ID]
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_Command_Details_Click:
Exit Sub

Err_Command_Details_Click:
MsgBox Err.Description
Resume Exit_Command_Details_Click

End Sub
  #2  
Old September 5th, 2006, 04:31 PM posted to microsoft.public.access.gettingstarted
Lynn Trapp
external usenet poster
 
Posts: 31
Default save record in continuous subform before opening child form

Try adding the following line to your code.

stLinkCriteria = "[People.People ID]=" & Me![People ID]
Me.Refresh
DoCmd.OpenForm stDocName, , , stLinkCriteria


--
Lynn Trapp
MS Access MVP
www.ltcomputerdesigns.com
Access Security: www.ltcomputerdesigns.com/Security.htm
Jeff Conrad's Access Junkie List:
http://home.bendbroadband.com/conrad...essjunkie.html



"Amanda Byrne" wrote in message
...
I have a Household form that has a continuous subform for all the People
that
reside in that household. The continuous subform has a command button
that
opens a "child"form where the user can add additional details for that
person
(add to their history, etc.)

This works well except when a new person is added to continuous subform,
when the command button is selected, the data added to the continuous
subform
has not been added to the database, and is not available for the child
form.
This can be avoided by clicking on a different record in the subform prior
to
opening the child form, but for ease of use, is there some code I could
add
to the command button that would save the current record so that the child
form opens properly?

Code on the command button:
Private Sub Command_Details_Click()
On Error GoTo Err_Command_Details_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "People"

stLinkCriteria = "[People.People ID]=" & Me![People ID]
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_Command_Details_Click:
Exit Sub

Err_Command_Details_Click:
MsgBox Err.Description
Resume Exit_Command_Details_Click

End Sub



  #3  
Old September 5th, 2006, 04:46 PM posted to microsoft.public.access.gettingstarted
John Spencer
external usenet poster
 
Posts: 7,815
Default save record in continuous subform before opening child form

Try adding the following line of code before the DoCmd.OpenForm

If Me.Dirty = True then Me.Dirty = False

That will force the record to be saved. Which is what clicking on a
different record in the subform was doing.
"Amanda Byrne" wrote in message
...
I have a Household form that has a continuous subform for all the People
that
reside in that household. The continuous subform has a command button
that
opens a "child"form where the user can add additional details for that
person
(add to their history, etc.)

This works well except when a new person is added to continuous subform,
when the command button is selected, the data added to the continuous
subform
has not been added to the database, and is not available for the child
form.
This can be avoided by clicking on a different record in the subform prior
to
opening the child form, but for ease of use, is there some code I could
add
to the command button that would save the current record so that the child
form opens properly?

Code on the command button:
Private Sub Command_Details_Click()
On Error GoTo Err_Command_Details_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "People"

stLinkCriteria = "[People.People ID]=" & Me![People ID]
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_Command_Details_Click:
Exit Sub

Err_Command_Details_Click:
MsgBox Err.Description
Resume Exit_Command_Details_Click

End Sub



 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 09:26 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.