Hi All
I have a Form1 and In this there is a list box Whose Rowsource property is set to
When an item on the listbox is clicked then another form "Form2" opens up that allows to make changes for the selected item from the listbox. When the changes are made and Save button is clicked then changes are made in tblmain.
Now After this I want to close the Form2 and Requery listbox on Form1 using VBA .
What code Do I need to use for that? Below is the code written in Form2 Save button. But Requery listbox thing at the end is not working.
I have a Form1 and In this there is a list box Whose Rowsource property is set to
Code:
Select * from tblmain where "DateWithdrawn=null"
When an item on the listbox is clicked then another form "Form2" opens up that allows to make changes for the selected item from the listbox. When the changes are made and Save button is clicked then changes are made in tblmain.
Now After this I want to close the Form2 and Requery listbox on Form1 using VBA .
What code Do I need to use for that? Below is the code written in Form2 Save button. But Requery listbox thing at the end is not working.
Code:
Private Sub cmdSave_Click()
'Me.txtHidden.SetFocus
Dim rs As Recordset
If ValidateForm = False Then Exit Sub
Set rs = CurrentDb.OpenRecordset("SELECT * FROM tbl_Mas_DocLog WHERE DocCode = '" & Me.txtCode & "'")
rs.Edit
rs!DocCode = Me.txtCode
rs!Owner = Me.cboOwner
rs!VersionID = Me.txtVersion
rs!Date_SignedOff = Me.txtDateSignedOff
rs!Date_Live = Me.txtDateLive
rs!Date_Expired = Me.txtDateExpires
rs!Date_Withdrawn = Null
rs!DocName = Me.txtDocName
rs!AreaID = Me.cboArea
rs!FileTypeID = Me.cboType
rs!Date_Withdrawn = Me.txtDateWithdrawn
rs!Comment = Me.txtComment
rs.Update
rs.Close
Set rs = Nothing
Set rs = CurrentDb.OpenRecordset("tbl_Ref_DocLogHistory")
rs.AddNew
rs!DocCode = Me.txtCode
rs!Owner = Me.cboOwner
rs!VersionID = Me.txtVersion
rs!Date_SignedOff = Me.txtDateSignedOff
rs!Date_Live = Me.txtDateLive
rs!Date_Expired = Me.txtDateExpires
rs!Date_Withdrawn = Null
rs!DocName = Me.txtDocName
rs!AreaID = Me.cboArea
rs!FileTypeID = Me.cboType
rs!CreatedDate = Date
rs!CreatedTime = Time()
rs!CreatedBy = GetUserName()
rs.Update
rs.Close
Set rs = Nothing
Forms!Form1!lstDue.Requery
Forms!Form1!lstOverDue.Requery
ClearDown
DoCmd.Close
End Sub