RecordsetType Property

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hello,

I am trying to understand the use of the RecordsetType property.

I place the statement

If me.CurrentRecord>1 Then
Me.RecordsetType=2
Else
Me.RecordsetType=0
End if

If the Form Current Event. However, this seem to have completely messed up
the db as it now seems to run code endlessly and never finishes opening the
form. i alwasy end up having to halt the code execution. Could someone
explain why what I thought was a simple IF statement make the db loop like
that? Also, is there a work around?

Thank you,

Daniel
 
According to Help:
"Note: Changing the RecordsetType property of an open form or report
causes an automatic recreation of the recordset."

This sets the CurrentRecord back to 1 and reinitiates the Form Current
event, which loops again, causing an endless loop.

--
--Roger Carlson
MS Access MVP
Access Database Samples: www.rogersaccesslibrary.com
Want answers to your Access questions in your Email?
Free subscription:
http://peach.ease.lsoft.com/scripts/wa.exe?SUBED1=ACCESS-L
 
Daniel said:
Hello,

I am trying to understand the use of the RecordsetType property.

I place the statement

If me.CurrentRecord>1 Then
Me.RecordsetType=2
Else
Me.RecordsetType=0
End if

If the Form Current Event. However, this seem to have completely
messed up the db as it now seems to run code endlessly and never
finishes opening the form. i alwasy end up having to halt the code
execution. Could someone explain why what I thought was a simple IF
statement make the db loop like that? Also, is there a work around?

Roger explained what's going on. For a workaround, what are you trying
to achieve, in a practical sense? If you just want to make the form
read-only, you can do it by setting its AllowEdits, AllowAdditions, and
AllowDeletions properties to False.
 
First off, Thank you Roger for the explanation!

Dirk, I have been asked to lock previous record but leave the most recent
open for editing. Thus record 1 should be dynaset and any other snapshot (in
my mind at least...). I did try the allowedits but it still permited my
users to make entries because they could still activate the double-click
event which opens a calendar and programatically made changes. Any
suggestions?

Thank you both once again.

Daniel
 
Daniel said:
First off, Thank you Roger for the explanation!

Dirk, I have been asked to lock previous record but leave the most
recent open for editing. Thus record 1 should be dynaset and any
other snapshot (in my mind at least...). I did try the allowedits
but it still permited my users to make entries because they could
still activate the double-click event which opens a calendar and
programatically made changes. Any suggestions?

I'm not sure what you mean by "most recent" -- whether you just want to
let users add records but not edit records that have previously been
saved, or whether you have something more complicated in mind -- but I
stil think your best bet is to manipulate the form's AllowEdits and
AllowDeletions properties. If you have an event procedure that modifies
a record using code, surely you can test in that procedure whether the
modification should be allowed or not, and simply refuse to do it.
 
Back
Top