I've decided to post my code... please make any suggestions you see fit, but please not major overhauls as I've spent too much time on this already and need to be moving on (although in saying that Adding/Updating/Deleting are essentials!)
I have dropping the opening and closing of the recordset as it was making no difference and resorted to my original code, which is displayed below.
Here is my code for the Add button:
Code:Private Sub cmdAdd_Click() txtStatus.Text = "Adding New Record..." 'db is globally dimmed Set db = New Connection db.CursorLocation = adUseServer db.Open "PROVIDER=Microsoft.Jet.OLEDB.4.0;" & "Data Source=" & ConnPath & "\DatabaseDB.mdb;" Dim InsertNewTask As String InsertNewTask= "INSERT INTO Task(TaskID) VALUES('" & txtTaskID & "')" db.Execute InsertNewTask End Sub
And here is my code for the Update button:
Code:Private cmdUpdate_Click() Dim db As Connection Set db = New Connection db.CursorLocation = adUseClient db.Open "PROVIDER=Microsoft.Jet.OLEDB.4.0;" & "Data Source=" & ConnPath & "\DatabaseDB.mdb;" Dim UpdateTaskRecord As String UpdateTaskRecord = "UPDATE Task SET TaskDescription='" & txtTaskDescription & "', TaskDate='" & txtTaskDate & "', TaskTime='" & txtTaskTime & "', CustomerID='" & txtCustomerID & "' WHERE TASK.TaskID='" & txtTaskID & "'" db.Execute UpdateTaskRecord txtStatus.Text = "Save Successful" If CStr(adoPrimaryRS.AbsolutePosition) = (-1) Then txtCount.Text = "Total: 0" Else: txtCount.Text = "Total: " & CStr(adoPrimaryRS.RecordCount) End If mbEditFlag = False mbAddNewFlag = False mbDataChanged = False Exit Sub If Not IsEmpty(adoPrimaryRS) Then cmdDelete.Enabled = True Else cmdDelete.Enabled = False End If End Sub
Please make any suggestions you think of. Thanks




Reply With Quote