Allow Edits

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

Guest

I have a form that is bound to a Customer Table. On that form, I have 4
different methods of searching the Table that are done through Unbound Combo
Boxes, Customer Name, Account No etc. In setting Me.allowedits = True, I
allow anyone to make changes to the record that is found. I don't want to do
this. I want the record to be "Read Only" until an "Edit Button" is selected.
If I set Me.Allowedits = False, I can not make a selection in the Combo Box.
I tried setting the Combo Boxes individualy by using
cmbFindAccountNo.AllowEdits = True but I get an error "Data member Not
Found". There must be a simple sollution that I am not seeing.
Any pointers please?

RayC
 
RayC said:
I have a form that is bound to a Customer Table. On that form, I have
4 different methods of searching the Table that are done through
Unbound Combo Boxes, Customer Name, Account No etc. In setting
Me.allowedits = True, I allow anyone to make changes to the record
that is found. I don't want to do this. I want the record to be "Read
Only" until an "Edit Button" is selected. If I set Me.Allowedits =
False, I can not make a selection in the Combo Box. I tried setting
the Combo Boxes individualy by using cmbFindAccountNo.AllowEdits =
True but I get an error "Data member Not Found". There must be a
simple sollution that I am not seeing.
Any pointers please?

RayC

Yes, it's a bit of a pain that AllowEdits applies to the Form rather than
the RecordSource which is why it affects your unbound controls as well.
Instead of using AllowEdits you can loop through all of your bound controls
and set the Locked property to True or False as required. What I usually do
is give all of the controls I want to change a common tag property like
"Lock" then the code is...

Dim cnt as Control

For Each cnt in Me
If cnt.Tag = "Lock" Then cnt.Locked = True
Next cnt
 
Hi Rick
Within your line "If cnt.Tag = "Lock" Then cnt.Locked = True", the part
"cnt.Locked" would be a lot more powerful if I could pass a variable to it.
For example if I could load the word "Locked" into "varA", would there be any
way I could be able to use the expression "cnt.varA" or something like
cnt.(varA). By doing that, I could pass "Locked" or "Visible" or "Enabled"
etc to the same Sub Routine and avoid repeating Code.
Thanks RayC
 
RayC said:
Hi Rick
Within your line "If cnt.Tag = "Lock" Then cnt.Locked = True", the
part "cnt.Locked" would be a lot more powerful if I could pass a
variable to it. For example if I could load the word "Locked" into
"varA", would there be any way I could be able to use the expression
"cnt.varA" or something like cnt.(varA). By doing that, I could pass
"Locked" or "Visible" or "Enabled" etc to the same Sub Routine and
avoid repeating Code.
Thanks RayC

For items in a collection you can use...

Forms!FormName
or
Forms("FormName")

....and the second syntax could use a variable. However; that does not
appear to work for referring to properties.
 
Hi Rick
Not sure I fully understand your reply but I think you are saying it can not
be done. Thanks anyway
RayC
 
Hi Rick
Sorry to keep coming back to you but I have a rather unusual problem when I
try to implement your code below. I have two Tables with very similar
information in them. Because they are two seperate tables, I have two forms
with which to look up information in those tables. I had a problem with
editing the information and you kindly pointed me in the right direction
below. Because I want to control how editing is done on both forms. I put
your code in the following format as a utility external to each forms code:-

Public Sub Lock_Unlock(frm As Form, a As Boolean)

Dim cntrl As Control
For Each cntrl In frm
If cntrl.Tag = "Lock" Then cntrl.Locked = a
Next cntrl

Exit Sub

And I call that from inside the two forms with Call
Lock_Unlock(Forms.frm_Enquiry_Cust,True).

Here is the rub, one form works fine and the other Form crashes. However. it
crashes on the 20th loop of the "If cntrl.Tag = "Lock" Then cmtrl.locked = a.
I must have som kind of duff control in that particular form but I can not
use debug print to find out which control it is. Any ideas?

Thanks RayC
 
RayC said:
Hi Rick
Sorry to keep coming back to you but I have a rather unusual problem
when I try to implement your code below. I have two Tables with very
similar information in them. Because they are two seperate tables, I
have two forms with which to look up information in those tables. I
had a problem with editing the information and you kindly pointed me
in the right direction below. Because I want to control how editing
is done on both forms. I put your code in the following format as a
utility external to each forms code:-

Public Sub Lock_Unlock(frm As Form, a As Boolean)

Dim cntrl As Control
For Each cntrl In frm
If cntrl.Tag = "Lock" Then cntrl.Locked = a
Next cntrl

Exit Sub

And I call that from inside the two forms with Call
Lock_Unlock(Forms.frm_Enquiry_Cust,True).

Here is the rub, one form works fine and the other Form crashes.
However. it crashes on the 20th loop of the "If cntrl.Tag = "Lock"
Then cmtrl.locked = a. I must have som kind of duff control in that
particular form but I can not use debug print to find out which
control it is. Any ideas?

The most likely reason for a problem there is that you set the Tag property
of a control to "Lock" on a control that does not have a Locked property
(like a label).
 
YaaaaaHooooo, Your a genius! Why could I not pick up on something like that?
Where would we be without you guys?
Thanks and sorry to pester you.

RayC
 
Back
Top