按下按钮后访问

时间:2015-07-10 04:41:35

标签: forms vba user-interface access-vba

在访问中,我有''主要'表单和一个按钮,在弹出窗口中打开另一个访问表单以填充日期。用户输入日期并在那里发表评论,然后按“保存”键。按钮。我希望这个日期立即显示在主表格中。

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

1 个答案:

答案 0 :(得分:0)

解决。关闭弹出窗体时创建新事件以保存数据。

Private Sub Form_Close()
Forms!frm_Kaizen_Cards!txt_P_Dates.Value = Forms!frm_P_Phase!txt_P_phase_date.Value
End Sub