Can anyone tell me what is wrong with this code? When I try to run it, I get an error saying that I tried to assign a null value to a variable that is not a variant data type. Thanks!
Private Sub Form_Current()
Dim s As String
Dim db As New ADODB.Connection
Dim rs As New ADODB.Recordset
Set db = CurrentProject.Connection
s = "SELECT Last(ERName) AS ERName FROM Staffing Other"
Set rs = New ADODB.Recordset
rs.Open s, db, adOpenDynamic, adLockOptimistic
'add to the table
With rs
Me![ERName] = .Fields("ERName")
End With
Set rs = Nothing
Set db = Nothing
End Sub
Private Sub Form_Current()
Dim s As String
Dim db As New ADODB.Connection
Dim rs As New ADODB.Recordset
Set db = CurrentProject.Connection
s = "SELECT Last(ERName) AS ERName FROM Staffing Other"
Set rs = New ADODB.Recordset
rs.Open s, db, adOpenDynamic, adLockOptimistic
'add to the table
With rs
Me![ERName] = .Fields("ERName")
End With
Set rs = Nothing
Set db = Nothing
End Sub