turnerk200
Programmer
Hi there, I am trying to refresh the recordsource on a subform - my code is below. When you click the add button once it doesnt refresh, when you click it twice it does - can anybody see what I am missing here. Thanks,
kt
Private Sub Command10_Click()
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim strsql As String
Set db = OpenDatabase("F:\My Documents\Karin\TaskManagementSystem\TaskMgmt.mdb")
strsql = "SELECT * FROM tbltimeActivity WHERE (((tblTimeActivity.matterno)=[forms]![frmtimetrack]![txtMatterNo]));"
Set rs = db.OpenRecordset("tblTimeActivity")
If IsNull(Forms!frmtimetrack!txtDate) Then
MsgBox "Please enter the date", vbOKOnly
DoCmd.GoToControl "txtDate"
ElseIf IsNull(Forms!frmtimetrack!txthours) Then
MsgBox "Please enter number of hours", vbOKOnly
DoCmd.GoToControl "txthours"
ElseIf IsNull(Forms!frmtimetrack!txtDescription) Then
MsgBox "Please enter the description of work", vbOKOnly
DoCmd.GoToControl "txtDescription"
Else
rs.AddNew
rs!MatterNo = Forms!frmtimetrack!txtMatterNo
rs!Date = Forms!frmtimetrack!txtDate
rs!hours = Forms!frmtimetrack!txthours
rs!description = Forms!frmtimetrack!txtDescription
rs!Owner = Forms!frmtimetrack!txtOwner
rs.Update
End If
Forms![frmtimetrack]![sfrmTimeAdd].Form.RecordSource = strsql
Forms![frmtimetrack]![sfrmTimeAdd].Form.Requery
rs.Close
db.Close
End Sub
kt
Private Sub Command10_Click()
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim strsql As String
Set db = OpenDatabase("F:\My Documents\Karin\TaskManagementSystem\TaskMgmt.mdb")
strsql = "SELECT * FROM tbltimeActivity WHERE (((tblTimeActivity.matterno)=[forms]![frmtimetrack]![txtMatterNo]));"
Set rs = db.OpenRecordset("tblTimeActivity")
If IsNull(Forms!frmtimetrack!txtDate) Then
MsgBox "Please enter the date", vbOKOnly
DoCmd.GoToControl "txtDate"
ElseIf IsNull(Forms!frmtimetrack!txthours) Then
MsgBox "Please enter number of hours", vbOKOnly
DoCmd.GoToControl "txthours"
ElseIf IsNull(Forms!frmtimetrack!txtDescription) Then
MsgBox "Please enter the description of work", vbOKOnly
DoCmd.GoToControl "txtDescription"
Else
rs.AddNew
rs!MatterNo = Forms!frmtimetrack!txtMatterNo
rs!Date = Forms!frmtimetrack!txtDate
rs!hours = Forms!frmtimetrack!txthours
rs!description = Forms!frmtimetrack!txtDescription
rs!Owner = Forms!frmtimetrack!txtOwner
rs.Update
End If
Forms![frmtimetrack]![sfrmTimeAdd].Form.RecordSource = strsql
Forms![frmtimetrack]![sfrmTimeAdd].Form.Requery
rs.Close
db.Close
End Sub