Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to Run a General String Code.

Status
Not open for further replies.

JLeo

Technical User
Feb 10, 2003
44
US
Hi,

I've got alot of textbox fields to enable/disable according to what value a user keys in.
eg:
Me!Text1.enabled= True (previously False)

Is there a way to make the nunber component a general one like

Me!ScnXX.enabled = True/False

where XX is the number which increments till it hits the value that the user has entered.

Below is my code:

Private Sub Text103_AfterUpdate()
Dim TCount As Integer, CurCount As Integer
Dim Str1 As String
TCount = Me!Text103.Value 'gets the total count value
CurCount = 1

For CurCount = 1 To TCount
Str1 = "me!scn" & Count & ".enabled=true"
?!?how to excute this command in Str1?!?
Next CurCount
End Sub

Any help is most apprecieated. Thanks.
 
Look up the Control object in Access help. From memory this has a Name property so you can replace the For loop in your post with something like (untested):

Code:
Dim ctl As Control
For Each ctl in Me!Controls
    For CurCount = 1 To TCount
        ctl.Enabled = (ctl.Name = "Scn" & CurCount)  
    Next CurCount
Next ctl

Does this help? [pc2]
 
In the Tag property of the controls that you want to affect place text character or string then use the example below

In the example below each tag has a single letter a, b, c .. etc in the tag property
TagList is then a space separated list of the letters that I want to have controls appear for.


Code:
Private Sub DisplayRelevantControls(TagList As String)
Dim intLetter As Integer
Dim ctrl As Control

For Each ctrl In Me.Controls
    If Len(ctrl.Tag) > 0 Then
        If InStr(TagList, ctrl.Tag) Then
            ctrl.Visible = True
        Else
            ctrl.Visible = False
        End If
    End If
Next
End Sub



'ope-that-'elps

G LS
accessaceNOJUNK@valleyalley.co.uk
Remove the NOJUNK to use.
 
Thanks for the suggestions. Currently i'm trying but in the
line:

For Each ctl In Me.Controls

I keep getting this error
Error:2645
Cant find the field 'control'refered to in your expression.

Is there a reference that i need to add in for this to work?
 
IF you have typed the Error message in correctly - as it apears - then I'd suggest you have a typo problem.

Look carefully at the "S" at the end of ControlS



'ope-that-'elps.

G LS
accessaceNOJUNK@valleyalley.co.uk
Remove the NOJUNK to use.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top