在访问中,我有'主'表单和一个按钮,在弹出窗口中打开另一个访问表单以填写日期。用户输入日期和评论,然后按"保存"按钮。我希望这个日期立即显示在主表单中。
The code to open new form:
Private Sub btn_P_Phase_Click()
Id = Me.txt_ID.Value
If Me.txt_ID > 0 Then
DoCmd.OpenForm "frm_P_Phase", acNormal, , , , acWindowNormal
End If
End Sub
以及用于保存日期和注释的附加表单中的代码:
Private Sub btn_Save_Click()
Dim int_msg As Integer
Dim cCont As Control
Dim rs As ADODB.Recordset
Dim sConnString As String
Me.txt_ID.SetFocus
Id = Me.txt_ID.Value
P_comment = Me.txt_P_comment.Value
P_Date = Me.txt_P_phase_date.Value
CurrentDb.Execute ("UPDATE CI SET Status = 'Plan', P_Date ='" & P_Date & "', P_comment = '" & P_comment & "' WHERE ID = " & Id & ";"), dbSeeChanges
DoCmd.Close acForm, "frm_P_Phase", acSaveYes
End Sub
我试着在我的主要形式中写一些类似的东西:
Private Sub frm_P_Phase_AfterUpdate()
Me.txt_P_Dates.Value = Forms!frm_P_Phase!txt_P_phase_date
DoCmd.RunCommand acCmdRefreshPage
End Sub
解决。创建了关闭弹出式表单以保存数据的新事件。
Private Sub Form_Close()
Forms!frm_Kaizen_Cards!txt_P_Dates.Value = Forms!frm_P_Phase!txt_P_phase_date.Value
End Sub