Hi all,
I had a strange problem with a simple recordset routine, but a search on Tek-Tips found me the answer in an archived thread. The poster never got a response though, so I don't know why it works! I want to develop what I've done so far, but I think I'll hit more problems.
Essentially, this code enables one user to see which record another user has open, via a table with static records.
I have this code in the forms Current event:
Dim dbsFaults As Database
Dim rstTypes As DAO.Recordset
Set dbsFaults = CurrentDb
Set rstTypes = dbsFaults.OpenRecordset("test")
rstTypes.FindFirst "user = " & "'" & CurrentUser & "'"
rstTypes.Edit
rstTypes!openrecord = me.recordnumber
rstTypes.Update
rstTypes.Close
So it opens the table "test" (names have been changed to protect the innocent. Or just to make it simple!), finds the operators record & enters the current record number in the "openrecord" field. If they move off the record, it updates it again. Works everytime.
I have an exit button on the form & added the identical routine to it. This time, it sets the "openrecord" to 'Null'.
This causes the error "operation not supported" on the findfirst line. Why, I have no idea! The first block still works, always updating the record number. The second block always tripped. I disabled the first block, the second still failed. I tried sticking them together & that did work; on current, I opened the recordset, changed the record, closed it, opened it again, changed the record to 'Null', closed it again. This worked. Utterly useless, looked stupid, but proved my code was in the correct fashion!
I found thread705-1037502 in which PHV suggested to the poster that they try:
Set rstTypes = dbsFaults.OpenRecordset("test", dbDynaset)
I made the change on the second block only & it does work. Can anyone (PHV maybe!) explain what that's doing? I'd simply like to understand it. I know the term dynaset, but why the difference?
Also, the database is on a terminal server & record locking doesn't seem to work properly. This could be used to help protect an open record eventually. Any comments would be appreciated!
I had a strange problem with a simple recordset routine, but a search on Tek-Tips found me the answer in an archived thread. The poster never got a response though, so I don't know why it works! I want to develop what I've done so far, but I think I'll hit more problems.
Essentially, this code enables one user to see which record another user has open, via a table with static records.
I have this code in the forms Current event:
Dim dbsFaults As Database
Dim rstTypes As DAO.Recordset
Set dbsFaults = CurrentDb
Set rstTypes = dbsFaults.OpenRecordset("test")
rstTypes.FindFirst "user = " & "'" & CurrentUser & "'"
rstTypes.Edit
rstTypes!openrecord = me.recordnumber
rstTypes.Update
rstTypes.Close
So it opens the table "test" (names have been changed to protect the innocent. Or just to make it simple!), finds the operators record & enters the current record number in the "openrecord" field. If they move off the record, it updates it again. Works everytime.
I have an exit button on the form & added the identical routine to it. This time, it sets the "openrecord" to 'Null'.
This causes the error "operation not supported" on the findfirst line. Why, I have no idea! The first block still works, always updating the record number. The second block always tripped. I disabled the first block, the second still failed. I tried sticking them together & that did work; on current, I opened the recordset, changed the record, closed it, opened it again, changed the record to 'Null', closed it again. This worked. Utterly useless, looked stupid, but proved my code was in the correct fashion!
I found thread705-1037502 in which PHV suggested to the poster that they try:
Set rstTypes = dbsFaults.OpenRecordset("test", dbDynaset)
I made the change on the second block only & it does work. Can anyone (PHV maybe!) explain what that's doing? I'd simply like to understand it. I know the term dynaset, but why the difference?
Also, the database is on a terminal server & record locking doesn't seem to work properly. This could be used to help protect an open record eventually. Any comments would be appreciated!