Hey, I recently switched over to using SQL for the backend of my Access databases. The codes I have use to work, all I have just modified them a little to be able to use the SSRS easier.
However since I made the changes I keep getting an error message stating:
I get the error message but it is still saving the data to SQL, but not clearing the fields. I have not encountered this issue before and I am not having any luck finding out how to fix it. :banghead:
However since I made the changes I keep getting an error message stating:
My code is basically the followingObject variable or With block not set
Code:
Private Sub Save_Click()
On Error GoTo ErrorHandler
Dim db As Database
Dim sn As Recordset
strCount = 0
If Not IsNull(Me.dp1) Or Me.dp1 <> "" Then
'If you are adding a new record, then this code will work, if you finding an existing record you will need a where clause and an edit instead of addnew
Set db = CurrentDb
Set sn = db.OpenRecordset("SELECT * FROM dbo_FIDataEntry ORDER BY ID DESC", dbOpenDynaset, dbSeeChanges)
sn.AddNew
sn!DateTime = Now()
sn![N/S] = "N"
sn!datapoint1 = Me.dp1
sn!datapoint2 = Me.dp2
sn!Name = Me.name
sn!Shift = Me.Shift
End If
'Updates and closes the record
sn.Update
sn.Close
'Clears the fields for the next entry
Me.dp1 = Null
Me.dp2 = Null
Me.Shift = Null
Me.operator = Null
Exit_ErrorHandler:
Exit Sub
ErrorHandler:
MsgBox Err.Description
Resume Exit_ErrorHandler
End Sub