2015-07-10 121 views
0

在訪問中,我有'主'表單和一個按鈕,在彈出窗口中打開另一個訪問表單來填充日期。用戶在那裏輸入日期和評論,然後按'保存'按鈕。我希望這個日期立即顯示在主窗體中。按下按鈕後訪問

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 
+0

已解決。我在Form_Close上創建了事件。 – user2702405

回答

0

解決。在關閉彈出式窗體上創建新事件以保存數據。

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