473,320 Members | 2,041 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Lock a Sub-Form from a Form control

** Any assistance you can provide would be greatly appreciated **

I have a main form with multiple sub-forms. On the main form, I have a
checkbox that corresponds with each sub-form, and this checkbox will
express the users desire to lock the ability to edit a corresponding
sub-form. To do this, I figure that each checkbox will have :
(1) the AfterUpdate property call a Macro or VB Module to execute the
setting of the Allow Edits property of the sub-form and
(2) the On Current or On Load property of each corresponding sub-form
will also check the value of the checkbox in the main form to
determine whether the Allow Edits value for this sub-form should be
Yes or No.

I have a Macro that sets the value for the sub-form and I have plugged
that into the AfterUpdate setting of the checkbox on the main form,
but I cannot find a way to insert a step before the SetValue part
which can evaluate the state of the checkbox and conditionally set the
value of the Allow Edits based on that value. I have also been playing
with the Visual Basic Code Editor my feable attempts are also failing.
Any help or insight you can provide would be helpful.

The VB code I have at the moment (but it is not compiling properly)
is:

Private Sub Locked_AfterUpdate()
If Forms!Form1!Locked = True Then SetValue [Forms]![SubForm1]![Allow
Edits] = No
Else: SetValue [Forms]![SubForm1]![Allow Edits] = Yes
End If

End Sub

** If the form element called Locked is checked, then set the form
property Allow Edits of SubForm1 to No, else set value to Yes.

Again, I appreciate any thoughts or help you can provide to either add
to the macro I have to do that evaluation of the form element value,
or adjust the code so it can be used in both the AfterUpdate property
of the checkbox and either the On Current or On Load properties of
each subform.
Nov 12 '05 #1
2 7559
Private Sub Locked_AfterUpdate()
[Forms]![SubForm1]!form.AllowEdits = Not(locked)
End Sub
ja*******@hotmail.com (Jason G) wrote in message news:<ae**************************@posting.google. com>...
** Any assistance you can provide would be greatly appreciated **

I have a main form with multiple sub-forms. On the main form, I have a
checkbox that corresponds with each sub-form, and this checkbox will
express the users desire to lock the ability to edit a corresponding
sub-form. To do this, I figure that each checkbox will have :
(1) the AfterUpdate property call a Macro or VB Module to execute the
setting of the Allow Edits property of the sub-form and
(2) the On Current or On Load property of each corresponding sub-form
will also check the value of the checkbox in the main form to
determine whether the Allow Edits value for this sub-form should be
Yes or No.

I have a Macro that sets the value for the sub-form and I have plugged
that into the AfterUpdate setting of the checkbox on the main form,
but I cannot find a way to insert a step before the SetValue part
which can evaluate the state of the checkbox and conditionally set the
value of the Allow Edits based on that value. I have also been playing
with the Visual Basic Code Editor my feable attempts are also failing.
Any help or insight you can provide would be helpful.

The VB code I have at the moment (but it is not compiling properly)
is:

Private Sub Locked_AfterUpdate()
If Forms!Form1!Locked = True Then SetValue [Forms]![SubForm1]![Allow
Edits] = No
Else: SetValue [Forms]![SubForm1]![Allow Edits] = Yes
End If

End Sub

** If the form element called Locked is checked, then set the form
property Allow Edits of SubForm1 to No, else set value to Yes.

Again, I appreciate any thoughts or help you can provide to either add
to the macro I have to do that evaluation of the form element value,
or adjust the code so it can be used in both the AfterUpdate property
of the checkbox and either the On Current or On Load properties of
each subform.

Nov 12 '05 #2
When refering to properties you need to use a . and not a !
Also, make the language of the checkbox option correspond to the property it
is affecting. In this case for instance, make the checkbox mean "Form is
UnLocked" and not "Form is Locked". this way you can simply use in the
checkboxes AfterUpdate event...

Me!subformcontrol.Form.AllowEdits = Me!checkbox.

If it is checked (True) then this sets the property to true and allows
editing, otherwise it will prevent them.

Also, use the OnLoad event of the main form to do the inital locking. In the
same manner.
Controls don't have OnLoad Events.

Your code is not compiling for a number of reasons.I
It is looking for a Fuction or Sub called SetValue, it won't look at
macros.
Second, ![AllowEdits] is a property, not a control, so refering to it in
this manner is not allowed.

Hope this makes sense.
Mike Storr
www.veraccess.com

"Jason G" <ja*******@hotmail.com> wrote in message
news:ae**************************@posting.google.c om...
** Any assistance you can provide would be greatly appreciated **

I have a main form with multiple sub-forms. On the main form, I have a
checkbox that corresponds with each sub-form, and this checkbox will
express the users desire to lock the ability to edit a corresponding
sub-form. To do this, I figure that each checkbox will have :
(1) the AfterUpdate property call a Macro or VB Module to execute the
setting of the Allow Edits property of the sub-form and
(2) the On Current or On Load property of each corresponding sub-form
will also check the value of the checkbox in the main form to
determine whether the Allow Edits value for this sub-form should be
Yes or No.

I have a Macro that sets the value for the sub-form and I have plugged
that into the AfterUpdate setting of the checkbox on the main form,
but I cannot find a way to insert a step before the SetValue part
which can evaluate the state of the checkbox and conditionally set the
value of the Allow Edits based on that value. I have also been playing
with the Visual Basic Code Editor my feable attempts are also failing.
Any help or insight you can provide would be helpful.

The VB code I have at the moment (but it is not compiling properly)
is:

Private Sub Locked_AfterUpdate()
If Forms!Form1!Locked = True Then SetValue [Forms]![SubForm1]![Allow
Edits] = No
Else: SetValue [Forms]![SubForm1]![Allow Edits] = Yes
End If

End Sub

** If the form element called Locked is checked, then set the form
property Allow Edits of SubForm1 to No, else set value to Yes.

Again, I appreciate any thoughts or help you can provide to either add
to the macro I have to do that evaluation of the form element value,
or adjust the code so it can be used in both the AfterUpdate property
of the checkbox and either the On Current or On Load properties of
each subform.

Nov 12 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Hon Seng Phuah | last post by:
Hi all, I have following code: use 5.004' use Fcntl ':flock'; sub check_file_status { $attempt_lock = 0;
7
by: John Bailo | last post by:
I'm seeing some odd locking behavior when using an DB2400 database and running an ado.net transaction. My code -- in simplified form, appears at the bottom. I want to run several INSERT...
5
by: Steven | last post by:
Can anyone tell me how to toggle the "Caps Lock" key? Thanks in advance
14
by: Gary Nelson | last post by:
Anyone have any idea why this code does not work? FileOpen(1, "c:\JUNK\MYTEST.TXT", OpenMode.Binary, OpenAccess.ReadWrite, OpenShare.Shared) Dim X As Integer For X = 1 To 26 FilePut(1, Chr(X +...
1
by: Doug Bell | last post by:
Hi, Can you lock the colum in a datagrid so that it can not be resized by th user? Thanks Doug
3
by: mpaine | last post by:
Hi everyone, I wrote some code and it seems ok to me but since it is going into a high-use production environment, I wanted some peer-review if possible. Basically, I wanted a way to know if an...
7
by: Spam Catcher | last post by:
Hi All, If I have a procedure that obtains a sync lock: Public Sub A SyncLock Myobject B() End SyncLock And another procedure which obtains the same synclock:
4
by: slinky | last post by:
I have a textbox that a user enters the current time (in this case at the end of a task, and it gets its value via a button's click event and getting its value from =Now() ). Is there a way to...
1
WyvsEyeView
by: WyvsEyeView | last post by:
I have a dataset subform on which I want to lock a field for just two specific records. Each record has a type_id and a desc field. I want to test the value of the type_id field for the current...
1
by: cmrhema | last post by:
Hi, Two questions 1. In windows application if we put on the below code, it will identify whether caps lock is on or not if (TextBox.IsKeyLocked(Keys.CapsLock)) { ...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.