recordsetType property from snapshot to dynaset (1 Viewer)

BPBP

Registered User.
Local time
Today, 01:49
Joined
Feb 27, 2009
Messages
64
I have a Main form(frmHistMain) and a sub form. by default, recordset type property of the main form is set to snapshot. and record locks set to all records. Hence the user cannot change anything.

my concept is to have a button to unlock the form, so the recordset property is to change to dynaset so that i can edit the form and its subform.

I have placed this a button on the form and put this 2 line code into the button on click event.

Forms!frmHistMain.RecordLocks = 0
Forms!frmHistMain.RecordsetType = 0

When i click the button, i note that the form refreshes, but when i try to select a field and edit, it beeps and does not allow edits. However if i manually go into design view and alter the record lock and recordset type property to no locks and dynaset and go back to form view, the button works as intended.

What is wrong?
 

DCrake

Remembered
Local time
Today, 09:49
Joined
Jun 8, 2005
Messages
8,632
I think you will find that you can only change this property in design mode not in view mode.
 

BPBP

Registered User.
Local time
Today, 01:49
Joined
Feb 27, 2009
Messages
64
I think you will find that you can only change this property in design mode not in view mode.

ooh okay so its not possible to do this with a button. Thanks.
 

gemma-the-husky

Super Moderator
Staff member
Local time
Today, 09:49
Joined
Sep 12, 2006
Messages
15,638
you are better to base the form on a dynaset, but set enableedits to false

then you cant edit anything

but you can change enableedits to true in code

me.enableedits = true, which "unlocks" the form.
 

BPBP

Registered User.
Local time
Today, 01:49
Joined
Feb 27, 2009
Messages
64
you are better to base the form on a dynaset, but set enableedits to false

then you cant edit anything

but you can change enableedits to true in code

me.enableedits = true, which "unlocks" the form.


I have a searchbox to retrieve the correct record at the header of the form. If i set enableedits to false, the user cannot use the searchbox to retrieve the record.

The original intention of this form is just for viewing only. The user only require to key in the id number and hit enter, the rest of the controls fills up with the information but these information should not be editable to prevent "accidents" from happening.

I was thinking of first setting the enableedit to false, and when the mouse moves over the search button, set me.enableedits = true. And then when the mouse moves off the search button, set me.enableedits = false.

Is there a mouse off event or alternative event?
 

gemma-the-husky

Super Moderator
Staff member
Local time
Today, 09:49
Joined
Sep 12, 2006
Messages
15,638
in that case,

set all the forms controls as enabled=true
locked=false then

when you open the form call this sub.
it will run without noticeable delay

Code:
sub lockfields
dim ctrl as control

from each ctrl in me.controls
  if ctrl.name<>"unlockedfield" then
     ctrl.locked=true
  end if
next
end sub
 

Users who are viewing this thread

Top Bottom