G
Graham
Hi,
Thanks for your help in advance.
I am trying to make the following code write but it keeps
telling me that it is read only.
Please can you tell me where I am going wrong.
Thank you.
Dim dbMyDB As DAO.Database
Dim rsMyRS As DAO.Recordset
Dim lngRecCount As Long
Dim ingInitial As Long
Dim NEWnumber As Long
Dim Number, Chars, MEnd, MonthN, MEnd1
Dim empold As Long
Dim weekold As Date
Set dbMyDB = CurrentDb
Set rsMyRS = dbMyDB.OpenRecordset("Expenses1 Query",
dbOpenDynaset)
NEWnumber = 10000
If rsMyRS.RecordCount <= 0 Then Exit Sub
rsMyRS.MoveLast
lngRecCount = rsMyRS.RecordCount
Text1 = lngRecCount
rsMyRS.MoveFirst
For ingInitial = 1 To lngRecCount
If rsMyRS!exp1emp = empold
Then 'no new employee
If rsMyRS!exp1weekend = weekold
Then 'no new date
Else
NEWnumber = NEWnumber +
1 'new inv no req
rsMyRS.Edit
rsMyRS!expNo = NEWnumber & "E"
rsMyRS.Update
End If
Else
NEWnumber = NEWnumber +
1 'new inv no req
rsMyRS.Edit
rsMyRS!expNo = NEWnumber & "E"
rsMyRS.Update
End If
empold = rsMyRS!exp1emp
weekold = rsMyRS!exp1weekend
Text3 = ingInitial
rsMyRS.MoveNext
Next ingInitial
rsMyRS.Close
dbMyDB.Close
Thanks for your help in advance.
I am trying to make the following code write but it keeps
telling me that it is read only.
Please can you tell me where I am going wrong.
Thank you.
Dim dbMyDB As DAO.Database
Dim rsMyRS As DAO.Recordset
Dim lngRecCount As Long
Dim ingInitial As Long
Dim NEWnumber As Long
Dim Number, Chars, MEnd, MonthN, MEnd1
Dim empold As Long
Dim weekold As Date
Set dbMyDB = CurrentDb
Set rsMyRS = dbMyDB.OpenRecordset("Expenses1 Query",
dbOpenDynaset)
NEWnumber = 10000
If rsMyRS.RecordCount <= 0 Then Exit Sub
rsMyRS.MoveLast
lngRecCount = rsMyRS.RecordCount
Text1 = lngRecCount
rsMyRS.MoveFirst
For ingInitial = 1 To lngRecCount
If rsMyRS!exp1emp = empold
Then 'no new employee
If rsMyRS!exp1weekend = weekold
Then 'no new date
Else
NEWnumber = NEWnumber +
1 'new inv no req
rsMyRS.Edit
rsMyRS!expNo = NEWnumber & "E"
rsMyRS.Update
End If
Else
NEWnumber = NEWnumber +
1 'new inv no req
rsMyRS.Edit
rsMyRS!expNo = NEWnumber & "E"
rsMyRS.Update
End If
empold = rsMyRS!exp1emp
weekold = rsMyRS!exp1weekend
Text3 = ingInitial
rsMyRS.MoveNext
Next ingInitial
rsMyRS.Close
dbMyDB.Close