?
Solved

what is the syntax

Posted on 2000-02-19
15
Medium Priority
?
152 Views
Last Modified: 2010-05-02
for i=0 to 12 step 1
with rs
.edit
.fields("ww & i &")=text(i).text
.update
end with
next i

the problem is the syntax ("ww & i &")
how to write the code? what is the correct syntax to pass the variable i into the code?

another problem also regarding syntax

how to write a for ........ loop code
i have 52 textboxes which name
ww1,ww2,ww3.......................ww52
i want to set them to invisible
how to use the for ......loop command to write for the code?
pls help
pp301t (form name)
ww1(textbox name)
the code i write is
for i=1 to 52 step 1
pp301t.ww & i.visible=false
it cannot work
what is the code
can anybody tell me
thanks u
0
Comment
Question by:keithtbe
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 4
  • 3
  • +2
15 Comments
 
LVL 12

Expert Comment

by:mark2150
ID: 2538124
try:

..fields("ww" & trim( str( i ) ) ) = ...

M
0
 
LVL 6

Expert Comment

by:Marine
ID: 2538132
OK you probably using DAO as your access method since ADO doesn't have it.
The problem you having now as follows. Your code starts looping from element 1. The fields collection have a base of 0. So if you have a conrol array of textboxes they must correspond to the fields collection in your table. YOu have to start you looping from 0.
for i = 0 to 13
rs.edit
rs(i) = text1(i).text
rs.update
next
this code should work since the i will be on the same level as field collection. I hope i am making sence having troulbe explaining this.
Now what is pp and that other stuff i don't understand you didn't give info on it.be more specific to make these textboxes visible or not just loop though them and set them to false if thas what you are trying to do.
0
 
LVL 1

Expert Comment

by:mmips
ID: 2538403
Marine... I think you mean 0 to 12...for 13 elements
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 6

Expert Comment

by:Marine
ID: 2538406
opps you correct !!
0
 

Author Comment

by:keithtbe
ID: 2539381
Edited text of question.
0
 
LVL 12

Expert Comment

by:mark2150
ID: 2539648
For you text boxes you should be using a control array. This is what arrays are for. Delete all but the first one and then start copying them again. When it asks "You already have a control named ... do you want to make an array?" say YES (or simply set the .Index property of the first control to '0')

In either case when you have the controls rebuilt you can code:

For Ndx = 0 to MyControl.Ubound
  Mycontrol(ndx).Visible = False
Next Ndx

M
0
 

Accepted Solution

by:
KevinHo earned 50 total points
ID: 2542950
For the problem of making the textboxes invisible use the controls array. To loop through and make the appropriate controls invisible.

i.e.

Dim conTemp As Control

For Each conTemp In Form1

If TypeOf conTemp Is TextBox And  
Left(conTemp.Name, 2) = "ww" Then

        conTemp.Visible = fasle

End If

Next

This is one solution. You can also make the textboxes a control array and use a normal for next loop.
0
 

Author Comment

by:keithtbe
ID: 2544534
if i dun want to use array textboxes
is that a possible way to make the text boxes invisible?
0
 
LVL 12

Expert Comment

by:mark2150
ID: 2544561
Yes, but a control array is cleaner and more managable.

M
0
 
LVL 6

Expert Comment

by:Marine
ID: 2544589
Maybe somethign like this.

Dim control As TextBox
For Each control In Form1.Controls
    If TypeOf control Is TextBox Then
        control.Visible = False
    End If
Next
0
 
LVL 12

Expert Comment

by:mark2150
ID: 2544630
KevinHo's answer is more general. Marines will turn all text boxes invisible, KevinHo's answer will just do those with matching names. My solution will do all elements of a control array.

Take your pick.

M
0
 
LVL 6

Expert Comment

by:Marine
ID: 2544639
I would go with your suggestion Mark because its more logical i suggested my example only because he didn't want to do it control array.
0
 

Expert Comment

by:KevinHo
ID: 2545229
I don't disagree with Mark or Marine, a control array containing the text boxes you want invisible is the neater and better solution. But if you don't want to do this then using the controls array on the form is an alternative solution.
0
 
LVL 12

Expert Comment

by:mark2150
ID: 2545850
Yep. They're all basically equivalent solutions. Pick one that suits your current app. Naturally I'm biased towards my answer, but KevinHo's is nice and Marines works as well.

Keithtbe, we haven't heard from you in a bit...

M

0
 

Author Comment

by:keithtbe
ID: 2546708
i really appreciate of what u suggested
because i have already set my form
it is really a big problem to change all the thing to array
so i really hope that that is a way to write a loop code to ease my problem
sigh
another thing
i really have a big problem of accepting those answer since all are well
another thing is this code can't work
Dim control As TextBox
                   For Each control In Form1.Controls
                       If TypeOf control Is TextBox Then
                           control.Visible = False
                       End If
                   Next
these maybe set all the textbox to invisible but what i want is part of it
but anyway
thanks u for ur help
so who should i give the point? can i give to u all?
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question