Reference: many to one

I have a form in which users enter information...I keep all controls
locked until the user hits a command button to unlock particular bound
controls.

This works really well, but becomes cumbersome to code when new
controls are added; e.g., adding the new control to the several event
procedures attached to the form.

Can anyone tell me how to refer to a group of controls once, e.g.,
give them a name; and then only have to refer to that name in the
future?

alex

0
alex
6/29/2007 5:58:32 PM
access 16762 articles. 3 followers. Follow

8 Replies
572 Views

Similar Articles

[PageSpeed] 16

Alex

I'm having trouble visualizing your situation.

It sounds like you are describing a form that is being regularly modified. 
If the underlying data is well-normalized, you would not need to be adding 
fields, so I'm not sure why you would need to be adding controls on your 
form.

Can you provide a bit more explanation of "why", not "how"?

Regards

Jeff Boyce
Microsoft Office/Access MVP

"alex" <sql_aid@yahoo.com> wrote in message 
news:1183139912.576277.39740@o61g2000hsh.googlegroups.com...
>I have a form in which users enter information...I keep all controls
> locked until the user hits a command button to unlock particular bound
> controls.
>
> This works really well, but becomes cumbersome to code when new
> controls are added; e.g., adding the new control to the several event
> procedures attached to the form.
>
> Can anyone tell me how to refer to a group of controls once, e.g.,
> give them a name; and then only have to refer to that name in the
> future?
>
> alex
> 


0
Jeff
6/29/2007 6:35:39 PM
On Jun 29, 2:35 pm, "Jeff Boyce" <nonse...@nonsense.com> wrote:
> Alex
>
> I'm having trouble visualizing your situation.
>
> It sounds like you are describing a form that is being regularly modified.
> If the underlying data is well-normalized, you would not need to be adding
> fields, so I'm not sure why you would need to be adding controls on your
> form.
>
> Can you provide a bit more explanation of "why", not "how"?
>
> Regards
>
> Jeff Boyce
> Microsoft Office/Access MVP
>
> "alex" <sql_...@yahoo.com> wrote in message
>
> news:1183139912.576277.39740@o61g2000hsh.googlegroups.com...
>
>
>
> >I have a form in which users enter information...I keep all controls
> > locked until the user hits a command button to unlock particular bound
> > controls.
>
> > This works really well, but becomes cumbersome to code when new
> > controls are added; e.g., adding the new control to the several event
> > procedures attached to the form.
>
> > Can anyone tell me how to refer to a group of controls once, e.g.,
> > give them a name; and then only have to refer to that name in the
> > future?
>
> > alex- Hide quoted text -
>
> - Show quoted text -

Thanks for responding Jeff...
I add controls from time to time beacuse of changes to what's being
captured.  Sometimes mgt decides it wants to capture information that
wasn't thought of during design time...regardless, I need to be able
to meet their expectations.

What I'm specifically talking about is naming controls in VBA.
E.g., if I want to unlock 10 controls in on click event of a command
button, I name all of them in my code.
I'm wondering if you can list all 10 somewhere, give them a group
name, and then refer to that name everytime you wanted to call the
controls in an event procedure.  Even if the data are well normalized,
I need to call every control in 4 or 5 different event procedures,
e.g., after update, on current, on click, etc.  If I could group them,
and then refer to the group name, that would save time.

Does that sound strange?  It seems like it would save a lot of time.

0
alex
6/29/2007 6:50:24 PM
alex <sql_aid@yahoo.com> wrote:

>Can anyone tell me how to refer to a group of controls once, e.g.,
>give them a name; and then only have to refer to that name in the
>future?

I've done this myself a number of times in the past.  You want to use the Tag
property of a control.    Every control that should be locked will have a value in
there such a "Lock"

Then in the Open event you pass in the OpenArgs from the calling form telling the
form if this is a new record.

    If Me.OpenArgs = "New" Then
        Call EnOrDis_AbleControlsOnForms(Me, tglLocked, True)
    Else
        Call EnOrDis_AbleControlsOnForms(Me, tglLocked, False)
    End If

I also added a Lock/Unlock command button which has the following code

    Call EnOrDis_AbleControlsOnForms(Me, tglLocked, tglLocked.Value)

This routine is in turn in  a public module.  It's a generic routine that will work
on any form.

Public Sub EnOrDis_AbleControlsOnForms(frm As Form, tgl As Control, _
	Optional Override As Boolean)
' Enable & unlock or disable and lock controls as required.  Controls must 
;      have Lock in the tag
' tgl is assumed to be a toggle control.  Note that the caption will be overwritten
' If Override value is true then the field will be unlocked

    Dim ctl As Control, ctlsbf As Control
    Dim Locked As Boolean
    
    On Error GoTo tagError
    
    If Not IsMissing(Override) Then
        Locked = Override
    Else
        Locked = tgl.Value
    End If

    For Each ctl In frm.Controls
        If ctl.Tag = "Lock" Then
            ctl.Enabled = Locked
            ctl.Locked = Not Locked
        End If
        If ctl.ControlType = acSubform Then
            For Each ctlsbf In ctl.Form.Controls
                If ctlsbf.Tag = "Lock" Then
                    ctlsbf.Enabled = Locked
                    ctlsbf.Locked = Not Locked
                End If
            Next ctlsbf
        End If
    Next ctl
    
    If Locked Then
        tgl.Caption = "Unlocked"
    Else
        tgl.Caption = "Locked"
    End If

    On Error GoTo 0
    Exit Sub

tagError:

    Select Case Err.Number
    '  This message happens on a subform control for unknown reasons
    '     something to do with the subform <shrug>
    Case 2164 ' You can't disable a control while it has the focus.
        ' ignore
        Resume Next
    Case Else
        MsgBox "Error " & Err.Number & " (" & Err.Description & ") in procedure
tglLocked_Click of VBA Document Form_Transaction Header"
    End Select
    Exit Sub
    Resume
    
End Sub

And thanks for reminding me that I should create a web page on this topic.

Tony
-- 
Tony Toews, Microsoft Access MVP
   Please respond only in the newsgroups so that others can 
read the entire thread of messages.
   Microsoft Access Links, Hints, Tips & Accounting Systems at 
http://www.granite.ab.ca/accsmstr.htm
   Tony's Microsoft Access Blog - http://msmvps.com/blogs/access/
0
Tony
6/29/2007 7:24:52 PM
Alex

One approach that might work for you would be to use the controls' "Tag" 
property.  You could use a single groupname (or a string of groupnames) in 
that property and check it in your code to see if what you are doing applies 
to that control.

Regards

Jeff Boyce
Microsoft Office/Access MVP

"alex" <sql_aid@yahoo.com> wrote in message 
news:1183143024.499517.172340@c77g2000hse.googlegroups.com...
> On Jun 29, 2:35 pm, "Jeff Boyce" <nonse...@nonsense.com> wrote:
>> Alex
>>
>> I'm having trouble visualizing your situation.
>>
>> It sounds like you are describing a form that is being regularly 
>> modified.
>> If the underlying data is well-normalized, you would not need to be 
>> adding
>> fields, so I'm not sure why you would need to be adding controls on your
>> form.
>>
>> Can you provide a bit more explanation of "why", not "how"?
>>
>> Regards
>>
>> Jeff Boyce
>> Microsoft Office/Access MVP
>>
>> "alex" <sql_...@yahoo.com> wrote in message
>>
>> news:1183139912.576277.39740@o61g2000hsh.googlegroups.com...
>>
>>
>>
>> >I have a form in which users enter information...I keep all controls
>> > locked until the user hits a command button to unlock particular bound
>> > controls.
>>
>> > This works really well, but becomes cumbersome to code when new
>> > controls are added; e.g., adding the new control to the several event
>> > procedures attached to the form.
>>
>> > Can anyone tell me how to refer to a group of controls once, e.g.,
>> > give them a name; and then only have to refer to that name in the
>> > future?
>>
>> > alex- Hide quoted text -
>>
>> - Show quoted text -
>
> Thanks for responding Jeff...
> I add controls from time to time beacuse of changes to what's being
> captured.  Sometimes mgt decides it wants to capture information that
> wasn't thought of during design time...regardless, I need to be able
> to meet their expectations.
>
> What I'm specifically talking about is naming controls in VBA.
> E.g., if I want to unlock 10 controls in on click event of a command
> button, I name all of them in my code.
> I'm wondering if you can list all 10 somewhere, give them a group
> name, and then refer to that name everytime you wanted to call the
> controls in an event procedure.  Even if the data are well normalized,
> I need to call every control in 4 or 5 different event procedures,
> e.g., after update, on current, on click, etc.  If I could group them,
> and then refer to the group name, that would save time.
>
> Does that sound strange?  It seems like it would save a lot of time.
> 


0
Jeff
6/29/2007 7:26:35 PM
On Fri, 29 Jun 2007 11:50:24 -0700, alex <sql_aid@yahoo.com> wrote:

>I'm wondering if you can list all 10 somewhere, give them a group
>name, and then refer to that name everytime you wanted to call the
>controls in an event procedure.  Even if the data are well normalized,
>I need to call every control in 4 or 5 different event procedures,
>e.g., after update, on current, on click, etc.  If I could group them,
>and then refer to the group name, that would save time.

One way to do this is to store the name of the group (or groups, if you want
to get fancy) in each control's Tag property. It's a text string that you can
use freely. 

Your code could loop through the Controls collection and change the properties
of every control with a particular value in Tag.

             John W. Vinson [MVP]
0
John
6/29/2007 9:09:11 PM
"Tony Toews [MVP]" <ttoews@telusplanet.net> wrote:

>        If ctl.Tag = "Lock" Then

That should use an Instr should you have multiple tags for different purposes.

Tony
-- 
Tony Toews, Microsoft Access MVP
   Please respond only in the newsgroups so that others can 
read the entire thread of messages.
   Microsoft Access Links, Hints, Tips & Accounting Systems at 
http://www.granite.ab.ca/accsmstr.htm
   Tony's Microsoft Access Blog - http://msmvps.com/blogs/access/
0
Tony
6/29/2007 9:52:16 PM
alex <sql_aid@yahoo.com> wrote:

>This works really well, but becomes cumbersome to code when new
>controls are added; e.g., adding the new control to the several event
>procedures attached to the form.

I decided to create a web page on this topic:

Locking fields on a form in Microsoft Access
http://www.granite.ab.ca/access/locking_fields_on_a_form.htm

Tony
-- 
Tony Toews, Microsoft Access MVP
   Please respond only in the newsgroups so that others can 
read the entire thread of messages.
   Microsoft Access Links, Hints, Tips & Accounting Systems at 
http://www.granite.ab.ca/accsmstr.htm
   Tony's Microsoft Access Blog - http://msmvps.com/blogs/access/
0
Tony
7/1/2007 8:48:50 PM
On Jul 1, 4:48 pm, "Tony Toews [MVP]" <tto...@telusplanet.net> wrote:
> alex <sql_...@yahoo.com> wrote:
> >This works really well, but becomes cumbersome to code when new
> >controls are added; e.g., adding the new control to the several event
> >procedures attached to the form.
>
> I decided to create a web page on this topic:
>
> Locking fields on a form in Microsoft Accesshttp://www.granite.ab.ca/access/locking_fields_on_a_form.htm
>
> Tony
> --
> Tony Toews, Microsoft Access MVP
>    Please respond only in the newsgroups so that others can
> read the entire thread of messages.
>    Microsoft Access Links, Hints, Tips & Accounting Systems athttp://www.granite.ab.ca/accsmstr.htm
>    Tony's Microsoft Access Blog -http://msmvps.com/blogs/access/

Thank you Tony, Jeff, and John for your help.  I really appreciate it.

alex

0
alex
7/2/2007 10:08:42 AM
Reply:

Similar Artilces:

Printing multiple worksheets on one page #3
Is this possible. I need to print 4 worksheets on one large page and print from the plotter. If not possible, any suggestions? Help . . . > Is this possible. I need to print 4 worksheets on one large page and > print from the plotter. If not possible, any suggestions? Help . . . One way is to use MS-Word. Insert a 2x2 table in a Word document. In each cell of the table, use either Insert >> Object >> Create from file or Insert >> Object >> Create new >> Microsoft Excel Worksheet If the ranges are smallish.... You could insert a new worksheet...

Best to have all one's styles in "Normal Template" ?
I assume one can save styles to other than one's Normal Template. Do the experts recommend also saving any added styles to the Normal Template so that one Template contains all of one's styles? Or perhaps, if it is advisable to have one template have them all, it is best to have that repository be a template other than the Normal Template? Thanks for any advice. -- Norm Hi Norm: I recommend having different templates for the different types of documents that you create. In them, I suggest keeping the built-in styles defined for each document type. I rar...

More than one graph on a page in Excel
A function in excel that allows you to place a number of diffrent graphs on one 'layout' page would be nice. Maybe a third 'Place graph on Layout x' would be a nice addition. ---------------- This post is a suggestion for Microsoft, and Microsoft responds to the suggestions with the most votes. To vote for this suggestion, click the "I Agree" button in the message pane. If you do not see the button, follow this link to open the suggestion in the Microsoft Web-based Newsreader and then click "I Agree" in the message pane. http://www.microsoft.com/offi...

Moving data in a large cell range to one row
I have data in cell range A1:R34. All of the data needs to be in column A. Instead of cutting and pasting each row or column in the range, is there a way to move all of this data quickly to column A? Thanks for the help. Hi and how do you want it to move into this column?. Best would be you give an example -- Regards Frank Kabel Frankfurt, Germany "Todd" <anonymous@discussions.microsoft.com> schrieb im Newsbeitrag news:1b3101c4a270$9123dce0$a301280a@phx.gbl... > I have data in cell range A1:R34. All of the data needs > to be in column A. Instead of cutting and ...

More than one vertical axis?
Hello, I am plotting year on the x-axis and trying to plot interest rate of the left vertical axis and dollars on the right vertical axis of a line graph. How do I set up a two (left and right) vertical axis chart? Please let me know, Thanks for your time Create a chart with both series (rates and dollars). Right-click on one of the series Choose Format Data Series On the Axis tab, select Secondary, click OK Dr. Darwin wrote: > I am plotting year on the x-axis and trying to plot > interest rate of the left vertical axis and dollars on the > right vertical axis of a line graph. ...

Trying to split up info in one cell to several
I am working on a home PC, Excel 2003. I have a column (it is column C of A thru K, if that matters) of data that includes street address (may include suite number, etc.), city, state, zip and all info is separated by commas except state and zip. I am trying to separate the information in this column so that each part is in its own column. I need to keep all of the address (street number, street name, PO box number, suite number, etc. together) in one field, city in the next field, then state, then zip. The problem I am having when converting text to columns using the comma as the d...

Selecting Many Non-Adjacent Rows Easily
In a spreadheet with 100's of rows, how do I easily or automatically select non-adjacent rows at a constant interval, eg every 5 rows of an 800 row sheet? Hi, Assign this macro to a keyboard shortcut. Sub jumpLines() jumpLine = 5 Selection.Offset(jumpLine, 0).Select End Sub jeff >-----Original Message----- >In a spreadheet with 100's of rows, how do I easily or automatically select non-adjacent rows at a constant interval, eg every 5 rows of an 800 row sheet? >. > What are you looking to achieve? It may be that there are far easier ways of doing what you want. -- ...

Address toolbar will show only one file
With multiple excel files open the address toolbar will only show one of these. It used to show all open files until I downloaded an Office update recommended by Microsoft after I sent off an error report for an Excel bug. Apologies for first message omitted - "appreciate if anyone could help" "Ian Grega" wrote: > With multiple excel files open the address toolbar will only show one of > these. It used to show all open files until I downloaded an Office update > recommended by Microsoft after I sent off an error report for an Excel bug. Ian Assuming you me...

How do I align numbers where one number has a dollar sign?
How do I align a column of numbers where the first number has a dollar sign? Like this, $280 60 50 Total $390 When I try to add the dollar sign, Excel "shifts" the number slightly more to the left of the other numbers, resulting in a slightly uneven alignment. Also, I'd like the dollar sign number to align w/ the total amt. What's the best way to do this? Probably Excel applies an accounting number format. Select the cell, and go to the Formatting dialog, Number tab, and select Custom. The Type box on the right says $#,##0_);[Red]($#,...

UTF-7 or UTF-8 which one?
Hi, I am changing the international options in Outlook 2003 to unicode and have two option Unicode UTF-7 and UTF-8. Would anybody know what is better or preferred, and if so why? Thanks Lisa ...

Problems with cell references
I have just updated to EXCEL 2003 and i have a large EXCEL2000 file. It has loaded ok, but, everytime I copy the cell reference changes (from ABCD for Columns and 1234 for rows, to R1C1 format i.e 1234 for both columns and rows) This changes all my formulas !!! I then have to go into options and unselect the R1C1 tick box. This chages it all back to ABCD etc Question is how do I keep normal references permantently I have tried selecting all sheets going to options and unselecting the tick box, then saving. This doesntseems to work ! Any suggestions Yours in frustration Paul Hi Pau...

Asset Reference Data for Multiple Location Companies
I am looking for suggestions on where best to place custom reference data for companies that have multiple locations. The same data is collected for each location and it is specific to the individual location. Our internal assesment suggests adding custom fields and tabs to the "more addresses" section would be the easiest option. This would require setting up a duplicate address for the Primary Company in order to record it's site data. We also considered using sub-accounts and adding a new option in the Service group. As I interpret it, the Microsoft documentation sugge...

Recipient Policies with more than one condition #2
Hi Guys, Listen i just had a server crash and i now need to resetup the Recipient policys for the various domains, I need to make a custom filter for anyone in a spefiic security group, and if possible i also would like it to contain a attribute of 1 for the distribution groups? I had is setup before for Description and and group attribute 1? but i think the first one would be better? please let me know as i can't recall the custom script???? Thanks in advance. Greg Remer Can you post what you want to do? Members of SecurityGroup1 OR Members of DistributionGroup1?? -- Bharat Sunej...

how to do a repeated operations with one keystroke
I print many orders in one day and end up doing the same seven steps everytime i want to print. i choose to save the file, i choose to print it to the printer, etx. Is there some way I can record those choices and have them all done when i just press one thing?? Have you tried recording a macro, then play the macro via pull down menus or from smartlist? -- dlothspe[MSFT]@online.microsoft.com This posting is provided "AS IS" with no warranties and confers no rights. Do not send e-mail directly to this alias. This alias is for newsgroup purposes only. "please please hel...

Allow only one user to access workbook at a time
I need to set excel to allow only one user at a time to access a workbook. The workbook is NOT a shared workbook, but it resides on a network share. Multiple users need to access it, but only One at a time. I want all other users to get a message that the file is in use and they can not open it. Is this possible? I believe that is the standard behavior of a network file that is not shared; users who access the file when it is in use get a message the file is in use and whether they want to open as Read Only. -- Greeting from the Gulf Coast! http://myweb.cableone.net/twodays "Emir_of_sh...

How to install a program on a Acer Aspire One
Hello I got the Acer Aspire One netbook computer. It does not have a CD reader. I would like to install the following program: Microsoft Office Standard Edition 2003 for students and teachers. I already have the program installed om my first computer. Microsoft in Sweden said that I was allowed to use the program on 3 computers so I want it in the Acer also. I have bought the program properly and I have the product key as well as the installation cd:s. I was hoping to find some homepage to download the program in exchange for my product key or something. 1. Doesn´t it ...

update one field from another
I know this will probably be an update query but my problem is how to. When I imported several hundred rows from my EXCEL sheets they did not have one of the fields we needed, the field "Location" in my table "Events" now how do I fill the "Location" field by whats in my "Code" field in my "Events" table. My Code field has 40 different codes and these codes have a specific location here how can I have COD put in the "Location" field when the "Code" field has 100SW in it. I am using ACCESS 2003. On Mon, 1 Oct 2007 06:...

.Net Mass Downloader Reference Source Debugable Under VS2005
Grab your copy from http://www.codeplex.com/NetMassDownloader/Wiki/View.aspx?title=Home It allows batch download, offline debugging and debug under 2005 for MS Permissive Licence Code. NET Mass Downloader Welcome to the .NET Mass Downloader project. While it's great that Microsoft has released the .NET Reference Source Code, you can only get it one file at a time while you're debugging. If you'd like to batch download it for reading or to populate the cache, you'd have to write a program that instantiated and called each method in the Framework Class Library. Fortunately, .NE...

two XP installs on one machine
Hi gang, Can I have a 98SE on C, and /TWO/ different XP installations on two other separate partitions? I have 98SE on C now and XP on E but would like to add a second - different - XP install on another partition. It seems adding one more line to boot.ini should do the job. Any comments? -- Mozart tells us what it's like to be human, Beethoven tells us what it's like to be Beethoven and Bach tells us what it's like to be the universe. - origin unknown "thanatoid" <waiting@the.exit.invalid> wrote in message news:Xns9DA7AC00A9D2Bthan...

RMS Store Operations should only allow one user in a PO.
One of my customers is having problems due to multiple users opening the same PO. This is the scenario he reports and I have verified in testing. He is on V1.2.0185. User one opens an existing PO and adds 100 line items. User two opens the same PO on a different Manager PC. User two adds one item and clicks OK, saving the change. User one then finishes his work on that same PO, clicks OK, and this error comes up. Data has changed! Another user has updated this record. The system cannot save your changes. All the changes to that PO from user one are lost. I understand why this error occ...

Event Sub when one specific cell changes
Hi, I am using Excel 2007. I have written a VBA Sub that I want to be called any time the value in one particular cell is changed. I know I can do this by creating a Worksheet_Change() Sub and checking the 'Target' Range parameter to see if the changed cell is the one I want to watch. The drawback of this is that this Sub gets called any time *any* cell is changed. In my case, this will get called alot because I have a value in another cell that changes once per second (it displays the current time). I was wondering if there is an event Sub other than Worksheet_...

Too Many Personal Folders
I move my outlook.pst file back and forth, by "import" between my home and laptop computers. I do not import duplicate entries. Somewhere in this process I have "acquired" several new Personal Folders. In the folder list there are four of them. The active data appears in the second one, counting from the top and the third and fourth seem to be duplicates. How do I safely reduce all my data to just one Personal Folder, and how do I prevent this growth in the future. TIA, Dave Harding in PA. Dave Harding <davejean1@comcast.net> wrote: > I move my outlook.pst...

terminate a thread from another one
Hi All, I have a worker thread (used AfxBeginThread) performing a lengthy operation. I want to give the user an option of stopping the process. This should terminate the worker thread. An option would be to use some class-level flag in an if statement and call AfxEndThread() . Is there not another way to do this, e.g communicating between threads. If yes, some sample code would be most helpful. Many thanks Since your worker thread is a loop, you should just exit out of the loop. You don't have to call AfxEndThread to end a worker thread. So set a flag in the worker threa...

copyinf a file with more then one data stream
downloaded an application programme from the vendor's site as a zip file. When attempting to copy it in a flash memory stick a warning pops up saying that that zip file contains more then one data stream but the destination volume does not support this feature. Some data will not be preserved as a result. What are these more then one data streams and will the destination file become unusable if I proceed with copying? aa wrote: > downloaded an application programme from the vendor's site as a zip file. > When attempting to copy it in a flash memory stick a warning...

GetPrivateProfileSectionNames only returning one section name
I was wondering if someone could tell me why the following code only returns a single section name of a multisection ini file. GetPrivateProfileSectionName(m_sReturnString,2000,m_sIniFile); MessageBox(m_sReturnString); Z.K. Never mind I figured it out. It had to do with the '\0' characters at the end of each string so I used a for loop to go through the string and set the '\0' to '\n' and now it prints out all the sections as it should. Z.K. "Z.K." <nospam@nospam.net> wrote in message news:%23SBeiAErGHA.3920@TK2MSFTNGP04.phx.gbl......