Access 2003: List of "TAG" property of all label controls

I have a DB created with Access 2003 on XP Pro SP3.
I would like to check the "TAG" property on all Label controls.
I can do it without problems if the forms are opened, but I haven't found yet a solution when the forms are closed.
I have found the below example on Access Help where it uses AllForms expression.
Unfortunately it returns only the form's name and it seems that there is no way to use the object AccessObject to manage the controls inside the form.

Dim obj As AccessObject, dbs As Object
Set dbs = Application.CurrentProject
' Search for open AccessObject objects in AllForms collection.
For Each obj In dbs.AllForms
If obj.IsLoaded = True Then
' Print name of obj.
Debug.Print obj.Name
End If

Sponsored Links:

Related Topics

For each... and the forms collection
Afternoon everyone! Wondered if you could help me out on this rather simple one.

What I need to do is add a string to the tag property of certain textboxes in certain forms in my DB. How do I say "for each form in currentdb.forms"? Here's what I've got so far:

Sub ReTag_Controls() Dim Frm As Form Dim ctl As Control For Each Frm In CurrentProject.AllForms
If InStr(Frm.Name, "Subform") Then
For Each ctl In Frm.Controls
If Not InStr(ctl.Name, "GPD") And Not InStr(ctl.Name, "_") And Not InStr(ctl.Name, "Tagged") And ctl.Type = acTextBox Then
ctl.Tag = ctl.Tag & "No_Export"
End If
Next ctl
End If Next Frm End Sub

I'm getting a type mismatch on the currentproject.allforms line. Grr.


Access 2003: How to have a Sequence Number Label Report print
Using Access 2003:
I have a form with:
Label starts at: ncount
Label sequence: nSequence
Number of Labels to print: nPagePrint
& other fields

When form Button form_Print_Button is selected
- the table (ncount,nSequence) is updated
- DoCmd.OpenReport "rptBarcodeFinishProductLabel", acViewPreview
- DoCmd.PrintOut acPages, 1, 1, , Me.nPagePrint

Everything Works Ok.
The only problem is I want each label to print
sequential number starting at: ncount
Label 1: . Box Number: 1 (assuming ncount=1 and nsequence=1)
Label 2: . Box Number: 2
Label 3: . Box Number: 3
Label 4: . Box Number


Modifying Label Caption in VBA Code from Form?
I have a form that opens a report, and before I open that report I'm trying to change the caption of a label on the report. I'm having troubles accomplishing this. The label is named lblFilter, I've tried.

Report_MyReport.Controls("lblFilter").Caption = txtDate.value
-----
Report_MyReport.lblFilter.Caption = txtDate.value

And, it just not working. I'm not sure how to reference that label's caption property properly.


Beyond my skillset.
I am using some code I found on the forum to track changes to my DB.

It works awesome however I was wondering if there is a way I can just write what changed in the mirror table versus the entire record.

Here is the Before Update Code:

Private Sub Form_BeforeUpdate(Cancel As Integer)
On Error Resume Next

' some controls may not have the Tag property ,
' hence the resume next

Dim blnCheckDiff As Boolean
Dim ctl As Control

blnCheckDiff = False
For Each ctl In Me.Controls
If ctl.Tag = "Check" And ctl.Value <> ctl.OldValue Then
blnCheckDiff = True
End If
Next
If blnCheckDiff Then
[Date_Edited] = Now()

Else
Cancel = True
End If
End Sub

And here is the After Update Code:

Private Sub Form_AfterUpdate()
Set db = CurrentDb
db.Execute "INSERT INTO [tbl_MINERAL_MineralOwner EDITS] " _
& " SELECT * FROM [tbl_MINERAL_MineralOwner] WHERE " _
& " [tbl_MINERAL_MineralOwner].[MineralOwner_ID]=" & Me![MineralOwner_ID]
Set db = Nothing


A2007 Some Combo Boxes changing back color on their own as they loose focus?
Access 2007 as really done it this time. On one form I have five Combo Box controls. I have been working most of the afternoon on UI formatting. Now 2 to 3 of the 5 controls SOMETIMES change their background color from white (asit should be) to the grey that is the form's background color.

Of the controls that do this, at least one SOMETIMES decides to stay white for some list values and only do the grey change color for some values.

Other controls consistently shift to grey when they loose focus.

Thus far, I was only able to find one page mentioning this on the Internet: "2007 Access Combo Box changes Background color after tab through f" [LINK]

I do not see the Alternate Color property on my A2007 Combo Box controls. I do see the property for the "Detail" portion of the Form the Control is placed on. I have already tried my Decompile / Compact / Compile process, and that did not correct the misbehavior.


Question about Northwind Splitform Controls
all,

I am looking at the NW example, and all of the buttons on the split forms look like this:

Can anyone tell what property is connecting the actual button to the detail section of the split form like that? That sort of thing happens automatically when you create a new columnar autoform in pre-07 versions, but I'm unsure of how to make one of those "connecting" type controls myself. each of them do have something in the TAG field, but it doesn't make much sense.

does anyone know what prop causes that? or how to make one


Invisible Controls In Form View/DE "No" Prop Issue
Yet again, buggy, frustrating, confounding Microsoft has managed to make a horrifyingly simple task inspire me to throw my PC out the window and shortly follow it. Consider this new gem:

I'm not getting existing table records showing up in Form View.

a) There's records in the table.
b) The form's Record Source currently contains one-to-one textbox controls from one table. The only control not sourced to that table is not currently sourced to ANYTHING.
c) The Form "Data Entry" property is set to "No"; the "Recordset Type" is "Dynaset (Inconsistent Updates)".for flexibility; the "Allow Additions" property is set to "Yes".
d) The Form Detail "Visible" property is set to "Yes".

Given those, why in the world would I not be seeing the 14 records in the source table, especially with the "Data Entry" property set to "No"?!


Visibility of other controls
Sometimes you want to control the visibility (or other property) of one control to be based on the value in another.

I have "Option 42" which is a Y/N selection.
I also have "Label 48" which I want to become active only if Option 42 is Yes.

What is the best thing to do in this situation


Dynamic Report Label Captions
I have been using this line of code to dynamically update label captions for my database.

Forms(strFormID).Controls(strLabelID).Properties(" Caption").Value = strlabelcaption

And I was curious if the same could be done for reports as well. I figured one way to est would to use the code below, but it didn't seem to work. Any pointers would be appriciated, thanks.

Reports(strReportName).Controls(strReportLabelID). Properties("Caption").Value = strlabelcaption


New Version of Invisible Controls In Form View/DE "No" Prop Issue
Yet again, buggy, frustrating, confounding Microsoft has managed to make a horrifyingly simple task inspire me to throw my PC out the window and shortly follow it. Consider this new gem:

I'm not getting existing table records showing up in Form View.

a) There's records in the table.
b) The form's Record Source currently contains one-to-one textbox controls from one table. The only control not sourced to that table is not currently sourced to ANYTHING.
c) The Form "Data Entry" property is set to "No"; the "Recordset Type" is "Dynaset (Inconsistent Updates)".for flexibility; the "Allow Additions" property is set to "Yes".
d) The Form Detail "Visible" property is set to "Yes".

Given those, why in the world would I not be seeing the 14 records in the source table, especially with the "Data Entry" property set to "No"?!

Confounding Mr. Gates. Confounding.

Mucho thanks ahead of time for advice on this normally/supposedly easy, yet persistent fix.
Windows XP, Access 2007, .accdb file


Creating Label Hyperlinks
I have a dashboard program with a "navigation" menu on the left. This "navigation" menu has labels that are filled in at runtime with one field of a recordset. I want each label that is filled in to then link back to the record it represents. Is this possible to do, and if so, what is the procedure. I have looked at the label object, hyperlink property, and I can't find a good example of how to link it (in code) to a single record


populate an label from an table
I like to know how can I populate an label.caption from an table

I have this: but it is populated just the first entry from table:

Private Sub Form_Load()
Me.Controls("Label1").Caption = DLookup("[company name]", "companies") End Sub


Set property of ALL controls in SubForm?
When user confirms his newly created records in a SubForm, I want all the Controls in the Subform to get "Transparent Background" and their 'Font' to be 'Bold'.

Will I have to write code for every single Control, or there is a way to apply a property to ALL Controls in SubForm?


How to use Access Columns Types in .NET
I need to know if there is way to figure out if a particular Column in an Access Table is of type "ComboBox" or "TextBox". For Example:

In Access I'm having a table "XYZ". This has 2 Columns "X" and "Y". In Access, I've assigned the "Display Control" tag (Open any Access Table->Go o to "Design View"-> Go to "Lookup" tab) as "Combobox" for Column "X" and as "TextBox" for Column "Y".

Is there a way that I can query this property in my C# code? i.e.

dc = DataTable.Columns[0];
if (dc.<To Figure Out>.ComboBox


Separating Labels and text boxes in Reports Access 2002
If I drag a field from my field list, how can I "undock" the label from the text box so I can rearrange the alignment of each field and label?

I know I can create blanks boxes and labels or use cut and paste, but using the field list is faster if I could figure out how to detach the label from it's text box.


Access 2007 - Change Backcolor Of Specific Labels
I have a series of labels on an Access Form.

Depending on the labels caption, I need to change the backcolor.

The first 5 characters of the labels will be the same (Cap x).

Example:
Cap 1-1
Cap 1-2
Cap 1-3
Cap 1-4
Cap 1-5

Cap 2-1
Cap 2-2
Cap 2-3
Cap 2-4
Cap 2-5

I want to change all labels where the number portion begins with 2, so I do this

Private Sub Command1_Click()
Dim ctrl As Control
For Each ctrl In Forms("NameOfForm").Controls
If TypeOf ctrl Is Label Then
If ctrl.Caption Like "Cap 2" Then
ctrl.BackColor = vbBlue
ctrl.ForeColor = vbWhite
End If
End If
Next
End Sub

All of the labels have their backstyle set to Normal.

The problem is that none of the labels are getting their backcolors changed. I put a break on the code and stepped through it.it is finding the controls on the form that are labels, but it is not find the label controls that have a caption like Cap 2.


Dlookup question
I am having a problem populating a unbound field (Year). I have a field named tag. Based upon the tag field I want to populate the unbound field Year. In my instanct Tag = 303KIE03 and year = 2002.

I have created the following dlookup statement:
Year = DLookup("[Year ]", "Vehicle", "[Tag ] = " & Me!Tag)

I get the following error:
Run-time error '3075'
Syntax error (missing operator) in query expression 'Tag = 303KIE03'.

I know I need to get single quotes around 303KIE03 but all of the combinations I use are invalid. Can you please provide the correct one


Option Explict not 100% protection
I have the following code:

Private Sub EditDisable()
Dim ctrl As Control
For Each ctrl In Me
With ctrl
If .Tag = "1" Then
.Enabled = False
.Locked = True
.BorderStyle = 0
End If
End With
Next End Sub

I inadvertantly omitted the dot from the .Tag property which should have made it a variable with a reserved name.
I would have expected the Option Explicit to at least reject it as an undefined variable but it doesn't. The code runs but of course the If condition is always False.

This suggests that Option Explicit ignores Property names even when they appear in a valid context for a variable but an invalid context for a property.


Text-Based Controls: The Label
A label is a control that serves as a guide to the user. It provides a static text that the user cannot change but can read to get information about another control on the form. You can also use it to display simple information to the user. Most controls on the form are not explicit at first glance and the user would not know what they are. Therefore, you can assign a label to the control as a help to the user.
Topcis: The Label, The Text Box, The Command Buttons, Combo and List Boxes, Radio Buttons, Check Boxes and Toggle Buttons.


Setting Properties for Multiple Objects in a Collection or Array Simultaneously
I have a form which includes an option group and multiple controls that I would like to hide if a user selects a certain option in the option group.

The option box is called fmeKnitWovenOther. There is a label called fmeKnitWovenOtherLbl that I would like to hide when any option is selected and a number of controls I would like to hide only if the user selects option 2.
[code]
The problem is that I have set the .visible property of every control individually, but I will need to expand this form and add more controls to be hidden for the other two options. If I keep setting the .visible property for every control manually, I am going to wind up with a giant list of controls all manually set to .visible = True and .visible = False depending on theIf or ElseIf condition.