Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

refreshing recordsource

Status
Not open for further replies.

turnerk200

Programmer
Mar 9, 2004
20
0
0
AU
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
 
Have you tried to close the recordset before the subform requery ?

Hope This Help, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Hi, thanks for your response, i tried it but still the same. It adds the data to the underlying table but the subform doesnt refresh.
 
Have you tried this ?
strsql = "SELECT * FROM tbltimeActivity WHERE matterno=" _
& Forms!frmtimetrack!txtMatterNo
If the column matterno isn't declared as numeric, try this:
strsql = "SELECT * FROM tbltimeActivity WHERE matterno='" _
& Forms!frmtimetrack!txtMatterNo & "'"

Hope This Help, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Tried both, still doesnt work, it works adding the second record but never the first.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top