Changing RecordSetType in a form

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

Guest

Here is my goal.
To a form open as either read-only or read-write based on the system user ID
info.
I have already got user ID solved with the help from another thread.
I would like to change the form's RecordSetType value based on a couple If
statements.

For example :
If user A opens the form, the RecordSetType = 0
If user B opens the form, the RecordSetType = 2

The problem that I run into is I cant seem to change the RecordSetType to
anything but the default setting in the form's properties.
I tried adding code to change the RecordSetType in the OnOpen or OnLoad of
the form, but no change could be made.
The form would always load to whatever was set in the defaults.
Questions :
Is there a way to set the RecordSetType while the form is opening?
Is there a way to change the RecordSetType of a form once it is open?

Also, I need to change the RecordSetType instead of opening the form as read
only because the combo boxes dont work.

Any ideas?
 
well, you didn't post your code, so we could help you troubleshoot it. in
lieu of that, here's the Example code from A2003 Help, in the RecordsetType
Property topic:
Example
In the following example, only if the user ID is ADMIN can records be
updated. This code sample sets the RecordsetType property to Snapshot if the
public variable gstrUserID value is not ADMIN.

Sub Form_Open(Cancel As Integer)
Const conSnapshot = 2
If gstrUserID <> "ADMIN" Then
Forms!Employees.RecordsetType = conSnapshot
End If
End Subhth
 
Hi Tina,
Thanks for the response.
Sorry for not including the code. I should have been more to the point.
I am just trying to change the RecordsetType property either during the
opening of a form or after its open.

The form RecordsetType default property is Dynaset (or 0).
The code that I am trying is simply " Me.RecordsetType = 2" to change the
property from the default of 0.
I add this code in the on_load and on_open and the form still opens as 0.
I have also tried the following vairations of code :

Forms!MyForm.RecordsetType =2

and

Const conSnapshot = 2
Forms!MyForm.RecordsetType = conSnapshot

and still had the same results.

Any other suggestions?
 
i tried the code in the Open event, and in the Load event, of a form in
A2000 running in A2003, and it worked fine. i also tried it on a command
button on the form itself, and was able to toggle the setting from Dynaset
to Snapshot and back, again without problem.

i tried the same code, with the same variations that you tried, in an A97
database running in A97, and it did not work at all. that's interesting in
light of the fact that the Help example code is the same in both versions of
Access.

so, no, i've no other suggestions - other than that you use code to loop
through the controls on the form and set the Locked properties to Yes.

hth
 
Hi Tina,
Thanks again. In everything I've read, it is supposed to work like it did
for you in A2003. But this is exactly what I ran into. It didnt work at
all. Figures.
I would do locks, but there is a huge number of controls on the form which
is why I was so interested in the RecordsetType.

If anyone else has a suggestion, please let me know!

Thanks!
 
ah, there you go. that's one great thing about these newsgroups; if there's
a way to handle issues like these, you can bet somebody else has already
figured it out! ;)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top