The following function works when used directly from a form. It locks
controls depending on a value stored in the tag property. Called from a
button on a subform, it does not work [UpdFormPropsLoc k(me.name, 3, true,
0)]. TIA.
Public Function UpdFormPropsLoc k(sForm As String, sLockLevel As Integer,
bSign As Boolean, Optional iJump As Integer) As Boolean
Dim sM1 As String
On Error Resume Next
If CurrentUserInGr oup("Quality 1") = False And CurrentUserInGr oup("Quality
2") = False And CurrentUserInGr oup("Admins") = False Then
sM1 = "You have not the authorization to perform this operation."
If sLang = "F" Then sM1 = DLookup("CtlVal ue_FR", "tblLang",
"FormName='0005 6'")
MsgBox sM1, vbExclamation
Exit Function
End If
Dim doc As Document
Dim frm As Form
Dim ctl As Control
Dim Prop As Property
Dim sA As String
Set frm = Forms(sForm)
For Each ctl In frm.Controls
For Each Prop In ctl.Properties
Select Case ctl.ControlType
Case acCheckBox, acOptionGroup, acTextBox, acComboBox, acListBox
If Prop.Name = "Tag" Then
If IsNull(Prop.Val ue) = True Or Prop.Value = "" Then
GoTo goto_next
ElseIf Prop.Value > 0 And Prop.Value <= CStr(sLockLevel ) Then
ctl.Locked = True
ElseIf Prop.Value > CStr(sLockLevel ) And Prop.Value <= "9" Then
ctl.Locked = False
End If
End If
Case acCommandButton
If Prop.Name = "Tag" Then
If Prop.Value > "0" And Prop.Value <= CStr(sLockLevel ) Then
If bSign = True Then frm!LockLevel.S etFocus
ctl.Enabled = False
ElseIf Prop.Value > CStr(sLockLevel ) And Prop.Value < "9" Then
If bSign = True Then frm!LockLevel.S etFocus
ctl.Enabled = True
End If
End If
Case acSubform
If Prop.Name = "Tag" Then
If Prop.Value <= CStr(sLockLevel ) Then
ctl.Enabled = False
ElseIf Prop.Value > CStr(sLockLevel ) Then
ctl.Enabled = True
End If
End If
End Select
goto_next:
Next Prop
Next ctl
frm!LockLevel = sLockLevel
frm.Refresh
UpdFormPropsLoc k = True
Set Prop = Nothing
Set ctl = Nothing
Set frm = Nothing
Set doc = Nothing
End Function 4 2321
No, it is not enough.
"Wayne Morgan" <co************ *************** @hotmail.com> wrote in message
news:eL******** *****@tk2msftng p13.phx.gbl... In the call, try changing Me.Name to Me.Parent.Name in order to send the
name of the main form.
-- Wayne Morgan Microsoft Access MVP
"Saintor" <sa******@REMOV ETHIShotmail.co m> wrote in message news:0v******** **********@wagn er.videotron.ne t... The following function works when used directly from a form. It locks controls depending on a value stored in the tag property. Called from a button on a subform, it does not work [UpdFormPropsLoc k(me.name, 3,
true, 0)]. TIA.
Public Function UpdFormPropsLoc k(sForm As String, sLockLevel As Integer, bSign As Boolean, Optional iJump As Integer) As Boolean Dim sM1 As String
On Error Resume Next
If CurrentUserInGr oup("Quality 1") = False And
CurrentUserInGr oup("Quality 2") = False And CurrentUserInGr oup("Admins") = False Then sM1 = "You have not the authorization to perform this operation." If sLang = "F" Then sM1 = DLookup("CtlVal ue_FR", "tblLang", "FormName='0005 6'") MsgBox sM1, vbExclamation Exit Function End If
Dim doc As Document Dim frm As Form Dim ctl As Control Dim Prop As Property Dim sA As String Set frm = Forms(sForm)
For Each ctl In frm.Controls
For Each Prop In ctl.Properties Select Case ctl.ControlType Case acCheckBox, acOptionGroup, acTextBox, acComboBox, acListBox If Prop.Name = "Tag" Then If IsNull(Prop.Val ue) = True Or Prop.Value = "" Then GoTo goto_next
ElseIf Prop.Value > 0 And Prop.Value <= CStr(sLockLevel )
Then ctl.Locked = True
ElseIf Prop.Value > CStr(sLockLevel ) And Prop.Value <= "9"
Then ctl.Locked = False End If End If
Case acCommandButton If Prop.Name = "Tag" Then If Prop.Value > "0" And Prop.Value <= CStr(sLockLevel ) Then If bSign = True Then frm!LockLevel.S etFocus ctl.Enabled = False ElseIf Prop.Value > CStr(sLockLevel ) And Prop.Value < "9"
Then If bSign = True Then frm!LockLevel.S etFocus ctl.Enabled = True End If End If
Case acSubform If Prop.Name = "Tag" Then If Prop.Value <= CStr(sLockLevel ) Then ctl.Enabled = False ElseIf Prop.Value > CStr(sLockLevel ) Then ctl.Enabled = True End If End If
End Select goto_next: Next Prop Next ctl
frm!LockLevel = sLockLevel frm.Refresh UpdFormPropsLoc k = True
Set Prop = Nothing Set ctl = Nothing Set frm = Nothing Set doc = Nothing
End Function
Ok, I took it that you were wanting to continue to lock the controls on the main form, but
place the button on the subform. Are you actually wanting to lock the controls on the
subform? You didn't specify WHAT doesn't work and WHAT you want it to actually do.
--
Wayne Morgan
Microsoft Access MVP
"Saintor" <sa******@REMOV ETHIShotmail.co m> wrote in message
news:mS******** **********@wagn er.videotron.ne t... No, it is not enough.
"Wayne Morgan" <co************ *************** @hotmail.com> wrote in message news:eL******** *****@tk2msftng p13.phx.gbl... In the call, try changing Me.Name to Me.Parent.Name in order to send the name of the main form.
-- Wayne Morgan Microsoft Access MVP
"Saintor" <sa******@REMOV ETHIShotmail.co m> wrote in message news:0v******** **********@wagn er.videotron.ne t... The following function works when used directly from a form. It locks controls depending on a value stored in the tag property. Called from a button on a subform, it does not work [UpdFormPropsLoc k(me.name, 3, true, 0)]. TIA.
Public Function UpdFormPropsLoc k(sForm As String, sLockLevel As Integer, bSign As Boolean, Optional iJump As Integer) As Boolean Dim sM1 As String
On Error Resume Next
If CurrentUserInGr oup("Quality 1") = False And CurrentUserInGr oup("Quality 2") = False And CurrentUserInGr oup("Admins") = False Then sM1 = "You have not the authorization to perform this operation." If sLang = "F" Then sM1 = DLookup("CtlVal ue_FR", "tblLang", "FormName='0005 6'") MsgBox sM1, vbExclamation Exit Function End If
Dim doc As Document Dim frm As Form Dim ctl As Control Dim Prop As Property Dim sA As String Set frm = Forms(sForm)
For Each ctl In frm.Controls
For Each Prop In ctl.Properties Select Case ctl.ControlType Case acCheckBox, acOptionGroup, acTextBox, acComboBox, acListBox If Prop.Name = "Tag" Then If IsNull(Prop.Val ue) = True Or Prop.Value = "" Then GoTo goto_next
ElseIf Prop.Value > 0 And Prop.Value <= CStr(sLockLevel ) Then ctl.Locked = True
ElseIf Prop.Value > CStr(sLockLevel ) And Prop.Value <= "9" Then ctl.Locked = False End If End If
Case acCommandButton If Prop.Name = "Tag" Then If Prop.Value > "0" And Prop.Value <= CStr(sLockLevel ) Then If bSign = True Then frm!LockLevel.S etFocus ctl.Enabled = False ElseIf Prop.Value > CStr(sLockLevel ) And Prop.Value < "9" Then If bSign = True Then frm!LockLevel.S etFocus ctl.Enabled = True End If End If
Case acSubform If Prop.Name = "Tag" Then If Prop.Value <= CStr(sLockLevel ) Then ctl.Enabled = False ElseIf Prop.Value > CStr(sLockLevel ) Then ctl.Enabled = True End If End If
End Select goto_next: Next Prop Next ctl
frm!LockLevel = sLockLevel frm.Refresh UpdFormPropsLoc k = True
Set Prop = Nothing Set ctl = Nothing Set frm = Nothing Set doc = Nothing
End Function
"Saintor" <sa******@REMOV ETHIShotmail.co m> wrote in message
news:0v******** **********@wagn er.videotron.ne t... The following function works when used directly from a form. It locks controls depending on a value stored in the tag property. Called from a button on a subform, it does not work [UpdFormPropsLoc k(me.name, 3, true, 0)]. TIA.
Public Function UpdFormPropsLoc k(sForm As String, sLockLevel As Integer, bSign As Boolean, Optional iJump As Integer) As Boolean
Dim doc As Document Dim frm As Form Dim ctl As Control Dim Prop As Property Dim sA As String Set frm = Forms(sForm)
It's not clear whether you want the function to operate on the controls on
the
subform or the controls on the parent form. Either way, I would change the
declaration
UpdFormPropsLoc k(sForm As String, to
UpdFormPropsLoc k(frmForm as Access.Form,
and then pass either Me or Me.Parent instead of trying to set the from
using the form's name and the Forms collection.
> Either way, I would change the declaration
UpdFormPropsLoc k(sForm As String, to UpdFormPropsLoc k(frmForm as Access.Form,
and then pass either Me or Me.Parent instead of trying to set the from using the form's name and the Forms collection.
This alone made the difference and solved my problem. Thanks to all. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Galina |
last post by:
Hello
I have an application in MS Access 2000. I have a form, which includes
a subform. The subform is based on a table, but locked for any
editing. There is Edit button. When clicked, it starts a separate
unbound form with all the fields, which are on the subform. The fields
are filled in with data programmatically. User edits. Edited fields
are copied into fields on the subform programmatically as well.
I need to catch change in one of...
|
by: A Clark |
last post by:
I have a subform that displays a datasheet. There are a couple of
different queries that can be displayed in the datasheet. The queries
are available in a combo box on the main form. The problem I am
having is that when I change the query all the column widths remain
the same. This doesn't look very good. I can't figure out a way to
set the column widths.
I have tried..
Subform.controls(Name of Column).columnwidth = IntColumnWidth
|
by: Susan Bricker |
last post by:
Greetings. I have a Mainform with a subform. The Mainform has single
record format and subform has continuous form format. When the Mainform
opens, I force allowadditions and allowedits to FALSE (for both the
Mainform and Subform). No problem there.
However, when I click on the navigation control of the subform to move
to the next record in the subform, the AllowAdditions and AllowEdits
changes to TRUE. Not good.
I set...
|
by: GaryDave |
last post by:
My school registration database has not been quite right after a recent
compact and repair (done while I was away). Though most of the many
forms and subforms are working normally, one form in particular will no
longer allow new entries into the subform - the recordset of the
underlying query is no longer updatable.
The subform in question enters the identity and other vital info for
children whose parent's ID provides the FK, linking...
|
by: vidiot |
last post by:
I am trying to create a subform that will display images related to the
parent form. The subform is a continuous form as there will be several
images that relate to the parent form.
I checked Access help and it gave me the following code, which I have
adapted for my database and it works well as a SINGLE FORM.
Option Compare Database
Private Sub Form_Current()
| |
by: ncsthbell |
last post by:
I have a form with a subform and I am trying to change the size of a column on the subform. I am following the instructions in the access help 'Change the layout of a subform in Datasheet view" to change the width but it is not working. The column source is a table and it appears that no matter how I size the column, it remains the size of the "name" of the column from the table. My subform has a FormHeader (with nothing defined for it) and...
|
by: Simon |
last post by:
Dear reader,
The syntax for the VBA code to change the RowSource of a Form is:
Forms!FormName..RowSource = "TableOrQueryName"
|
by: MPat |
last post by:
Hi!! I've been trying to figure this out..
I have a form with a subform and I need to display 2 different things in this subform, that's why I came with the idea of changing the Link Child Field and the Link Master Field.
This change should happen when clicking a button, so it would be helpful if somebody has an idea of how to change these fields in Visual Basic!!
The links between the forms actually work if I change the fields...
|
by: AccessIdiot |
last post by:
This is driving me nuts.
I have an unbound textbox (txt_SumSize) in my subform that holds the total of a field (Debitage_Size_Quantity)seen in datasheet view (control source =Sum().
I have an unbound textbox on my form (txt_SizeTotal) that gets the value from the subform footer when the form loads:
Private Sub Form_Load()
Me.txt_SizeTotal = Me!sbfrm_DEBITAGE_Size.Form!
End Sub
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |