Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Recordset question... 1

Status
Not open for further replies.

Najemikon

Technical User
Mar 5, 2002
168
GB
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!
 
Hi,

It seems to me that you cannot set the field in the table to null. Check your table definition if null is allowed or not. What is the typ of "openrecord" ?

EasyIt
 
Hi,

Thanks for the reply. "Openrecord" is an integer field & I can set it to null. The code as it stands, complete with dbDynaset, does work.

The thread where I got that answer has been archived with no reply explaining what it did. I'd just like to know why dbDynaset makes such a difference so I develop it correctly.


Cheers!



Jon
 
You have about 4 ways to open a recordset.
ie Forward Only. - Cursor can only move forward rstTypes.MoveNext NOT rstTypes.MoveBack.
NO UPDATES ALLOWED.

Dynaset allows any movement & UPDATES.

I forget the others, SnapShot?

Some open quicker that others also...
 
Thanks, Zion. That makes more sense & is very helpful. Wouldn't dbsFaults.OpenRecordset("test") open as Dynaset by default? If so, why did I have to force it for the second block? Anyway, I'll have a closer look now I know you can't assume direction.

Cheers!
 
Yes, I thought the default was dynaset, but I could be wrong.

Have fun! :eek:)

Alex Middleton
 
No, DOA, the default is "Table-Type", definately Not dynaset.

Table-Type - Updateable, can use indexes (Seek Method)
Dynaset-Type - Updateable, can be used with SQL statements, good for Large recordsets

Snapshot-Type - NOT updateable, very fast with recordsets around 500 records

Forward-Only-Type - NOT Updateable, can move forward only
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top