473,808 Members | 2,745 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

A97 update all Command Button and Textbox Caption properties?

MLH
This is one for you gurus. Someone has undoubtedly already done this.
How difficult would it be to recurse all command buttons and textbox
controls on all forms, appending an incrementing number to the end of
their Caption property strings? Say I have 10 forms with 10 such
controls each, I would like to have " (001)" - " (100)" appended to
the end of each of their Caption property strings.

Of course, I know about the manual brute force technique. I would
like to automate the job with a procedure in a class module.
Nov 13 '05 #1
5 3987
The trick to doing this would be to do them in the order you desire.

To loop through the controls, open the form in design view, loop through the
controls, see what type of control each is, and concatenate the number onto
the current caption.

Untested, very general, example:

Dim ctl As Control, strForm As String, intButton As Integer, intTextbox As
Integer
'create a loop here to go through all of the forms
strForm = "frmFormNam e"
DoCmd.OpenForm strForm,acDesig n,,,,acHidden 'hidden is optional
For Each ctl In Forms(strForm). Controls
If ctl.ControlType = acCommandButton Then
intButton = intButton + 1
ctl.Caption = ctl.Caption & intButton
End If
If ctl.ControlType = acLabel Then
'get the associated control, is it a textbox?
If ctl.Parent.Cont rolType = acTextbox Then
intTextbox = intTextbox + 1
ctl.Caption = ctl.Caption & intTextbox
End If
End If
Next
DoCmd.Close acForm, strForm, acSaveYes

--
Wayne Morgan
MS Access MVP
"MLH" <CR**@NorthStat e.net> wrote in message
news:l7******** *************** *********@4ax.c om...
This is one for you gurus. Someone has undoubtedly already done this.
How difficult would it be to recurse all command buttons and textbox
controls on all forms, appending an incrementing number to the end of
their Caption property strings? Say I have 10 forms with 10 such
controls each, I would like to have " (001)" - " (100)" appended to
the end of each of their Caption property strings.

Of course, I know about the manual brute force technique. I would
like to automate the job with a procedure in a class module.

Nov 13 '05 #2
PS.

One thing I thought of after doing that though is that Access 97 doesn't
have an AllForms Collection. To loop through the forms in Access 97 and open
them you'll need to open a recordset on the system table MSysObjects. Open
the recordset as a Snapshot so that you don't accidentally make changes to
this table. You will need to get the value from 2 fields. The Type field
will tell you if the object is a form. The Type value for a form is -32768.
The Name field will then give you the name of the form so that you can open
it.

--
Wayne Morgan
MS Access MVP
"MLH" <CR**@NorthStat e.net> wrote in message
news:l7******** *************** *********@4ax.c om...
This is one for you gurus. Someone has undoubtedly already done this.
How difficult would it be to recurse all command buttons and textbox
controls on all forms, appending an incrementing number to the end of
their Caption property strings? Say I have 10 forms with 10 such
controls each, I would like to have " (001)" - " (100)" appended to
the end of each of their Caption property strings.

Of course, I know about the manual brute force technique. I would
like to automate the job with a procedure in a class module.

Nov 13 '05 #3
Wayne Morgan wrote:
PS.

One thing I thought of after doing that though is that Access 97 doesn't
have an AllForms Collection. To loop through the forms in Access 97 and open
them you'll need to open a recordset on the system table MSysObjects. Open
the recordset as a Snapshot so that you don't accidentally make changes to
this table. You will need to get the value from 2 fields. The Type field
will tell you if the object is a form. The Type value for a form is -32768.
The Name field will then give you the name of the form so that you can open
it.


Wayne, I disagree that you need to open a recordset on MSysObjects. The
following code will list the forms in the mdb. It's easy enough to
expand it to open the forms like to you did in the prior post. I can do
the same with Reports and Modules.

Sub ListFormNames
Dim dbs As Database
Dim doc As Document
Dim i As Integer

Set dbs = CurrentDb

'change the word Forms to Reports or Modules for their list of names
With dbs.Containers! Forms
For Each doc In .Documents
i = i + 1
Debug.Print i & " " & doc.name
Next doc
End With

MsgBox "Done"
End Sub
Nov 13 '05 #4
Thanks Salad,

I guess I'm going to need to reload Access 97. Trying to just remember what
it had and didn't have doesn't cut it.

--
Wayne Morgan
MS Access MVP
"Salad" <oi*@vinegar.co m> wrote in message
news:mi******** *********@newsr ead2.news.pas.e arthlink.net...
Wayne Morgan wrote:

Wayne, I disagree that you need to open a recordset on MSysObjects. The
following code will list the forms in the mdb. It's easy enough to expand
it to open the forms like to you did in the prior post. I can do the same
with Reports and Modules.

Sub ListFormNames
Dim dbs As Database
Dim doc As Document
Dim i As Integer

Set dbs = CurrentDb

'change the word Forms to Reports or Modules for their list of names
With dbs.Containers! Forms
For Each doc In .Documents
i = i + 1
Debug.Print i & " " & doc.name
Next doc
End With

MsgBox "Done"
End Sub

Nov 13 '05 #5
Wayne Morgan wrote:
Thanks Salad,

I guess I'm going to need to reload Access 97. Trying to just remember what
it had and didn't have doesn't cut it.

:-)

I have Office2003 sitting in a folder, not installed. Someday I guess
I'm going to have to get with the game and move to it.
Nov 13 '05 #6

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

Similar topics

3
6785
by: David | last post by:
Hi, I need a button shown for each record (cont. form) with specific captions on each. I have a notes form for each record. When a user presses the button they can read the notes. I want to display a caption on the button to state either "Order Notes" or "READ NOTES". I placed a label over the button, and depending if the notes field is
2
2882
by: Joe Fetters via .NET 247 | last post by:
Have googled and read the VS.NET documentation can't seem to getthe answer to the following. Environment: Framework 1.1 VB.NET WinForm Access database Using all automagic tools (DataAdapter Wizard with generatedDataset and generated Select, Update, Insert and Deletecommands, controls bound to DataSet using the AdvancedDatabinding properties) Issue: Do I have to set parameters before I issue theDataSet.Update(Dataset, )? Again, my...
5
2603
by: Stephen Plotnick | last post by:
I'm very new to VB.NET 2003 Here is what I have accomplished: MainSelectForm - Selects an item In a public class I pass a DataViewRow to ItemInformation1 Form ItemInformation2 Form
3
5331
by: afr0ninja | last post by:
Hello! I'm currently working on a form that has several input fields and a subform. What I'm trying to accomplish is that when I first open the form I'd like to have the input fields displayed only. The fields are about 3" wide. Then I'd like to have a command button that when pushed it would expand the form to about 9" displaying the subform along with the input fields. The command button could then be pressed again to shrink the...
0
1695
by: Mark | last post by:
I want to create a user control inherited from a TextBox with an associated label (let's call it a LabelTextBox). The trick is that I want the control to inherit from TextBox and have all of its properties available rather than the default properties of the user control. I also do not want to have to expose the Textbox properties one by one in a user control. I have already previously created this control using Delphi and I have...
5
3481
by: Slavan | last post by:
I have an update statement that I'm executing against Oracle database from my C# code and it won't work. UPDATE MenuCaptions SET Caption = N@Caption WHERE MenuId = @MenuId AND CultureId = @CultureId Caption is an nvarchar type. MenuId and CultureId are integers. I get Exception with the following message: ORA-00933: SQL command not properly ended. It seems that problem lies in Caption column, because when I changed
11
6073
by: SAL | last post by:
Hello, I have a Gridview control (.net 2.0) that I'm having trouble getting the Update button to fire any kind of event or preforming the update. The datatable is based on a join so I don't know if that's what's causing the behavior or not. It seems like the Update button should at least do something. When the Edit button is clicked, the grid goes into Edit mode and the Cancel button takes the grid out of Edit mode. So, I don't get what...
1
948
by: Manojthanal | last post by:
I am doing a project with VB6 and Access usin DSN Method. But I cant run the edit command When clicking on Update Button then Run time Error is Comming i.e. Run-time error- '2147217900 (80040e14)': Extra) in queryexpression"a')
2
2642
by: sirdavethebrave | last post by:
Hi guys - I have written a form, and a stored procedure to update the said form. It really is as simple as that. A user can go into the form, update some fields and hit the update button to update the information which is stored in a SQL database. In testing we noticed that the form was updating correctly but the update mechanism was also updating the first record of the table in the sql database every time. No error messages are on...
0
9721
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9600
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,...
0
9198
agi2029
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...
1
7651
isladogs
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...
0
6880
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5548
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...
0
5686
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3860
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3011
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.