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. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
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
|
|||
|
|||
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
|
|||
|
|||
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 | |
|
|