Hi All,
I've put together a piece of code that allows me to modyfy Access reccords from my Excel tracking sheet.
The code takes a refference number from a cell in Excel and then finds this refference no in Access to modify records linked to it.
It all works fine in my dummy database, but when I implement it to the real thing an error occurs.
The error that I am getting is related to the ADO find function and reads:
Run-time error '3021':
Either BOF or EOF is True, or the current reccord has been deleted. Requested operation requires a current reccord.
After some simple trouble shooting, I've noticed that this is caused by the fact that all refference numbers in Access are formated as text.
Here is the code:
Sub find_and_ammend()
Dim cnn1 As New Connection
Dim rsJobs As Recordset
Dim find As String
find = ActiveCell.Value
cnn1.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=C:\Documents and Settings\Fidel\My Documents\Personal\SQL" & _
"\ae.mdb;"
Set rsJobs = New ADODB.Recordset
rsJobs.Open "Jobs", cnn1, adOpenKeyset, _
adLockPessimistic
rsJobs.find "JobReference= ' " & find & "'"
rsJobs.Fields("memo") = rsJobs.Fields("memo") & "My text here"
rsJobs.Update
Debug.Print rsJobs.Fields("memo")
rsJobs.Close
End Sub
Has any body got an idea How can I work aroud this?
Changing the refference numbers or adding another collumn with seccond refference number is not an option.
Cheers,
Slawek
I've put together a piece of code that allows me to modyfy Access reccords from my Excel tracking sheet.
The code takes a refference number from a cell in Excel and then finds this refference no in Access to modify records linked to it.
It all works fine in my dummy database, but when I implement it to the real thing an error occurs.
The error that I am getting is related to the ADO find function and reads:
Run-time error '3021':
Either BOF or EOF is True, or the current reccord has been deleted. Requested operation requires a current reccord.
After some simple trouble shooting, I've noticed that this is caused by the fact that all refference numbers in Access are formated as text.
Here is the code:
Sub find_and_ammend()
Dim cnn1 As New Connection
Dim rsJobs As Recordset
Dim find As String
find = ActiveCell.Value
cnn1.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=C:\Documents and Settings\Fidel\My Documents\Personal\SQL" & _
"\ae.mdb;"
Set rsJobs = New ADODB.Recordset
rsJobs.Open "Jobs", cnn1, adOpenKeyset, _
adLockPessimistic
rsJobs.find "JobReference= ' " & find & "'"
rsJobs.Fields("memo") = rsJobs.Fields("memo") & "My text here"
rsJobs.Update
Debug.Print rsJobs.Fields("memo")
rsJobs.Close
End Sub
Has any body got an idea How can I work aroud this?
Changing the refference numbers or adding another collumn with seccond refference number is not an option.
Cheers,
Slawek
Last edited: