Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Loop through elements of a continuous form

Posted on 2002-03-19
5
Medium Priority
?
1,310 Views
Last Modified: 2012-08-14
Hi,

Hope this doesn't sound too confusing...

How do I loop through a specific textbox on a form that is repeated any number of times? (continuous versus single page).

What I need to be able to do is check the value of each textbox.

Thanks in advance,

David.
0
Comment
Question by:DSE
  • 3
  • 2
5 Comments
 
LVL 12

Expert Comment

by:Paurths
ID: 6879630
hi DSE,

here is an example that will 'visit' each textbox on a form, and display its data in a messagebox

Private Sub cmdLoopTXT_Click()
Dim ctrl As Control

    For Each ctrl In Me.Controls
        If TypeOf ctrl Is TextBox Then
            MsgBox ctrl.Value
            'do your action here
        End If
    Next ctrl
End Sub


cheers
Ricky
0
 

Author Comment

by:DSE
ID: 6879672
Hi Ricky,

I have tried to modify the code you wrote but I seem to be having some trouble implementing it. The repeated form has well over 100 records displayed but the code appears to only loop through 3 of them.

Can you help?

Thanks,

David.

This is the code I used:
------------------------

Dim ctrl As Control

For Each ctrl In Me.Controls

If TypeOf ctrl Is TextBox Then
   If SBSP = Null Then
      MsgBox "ok"
    End If
Else
End If

Next ctrl
0
 

Author Comment

by:DSE
ID: 6879674
sorry...SBSP is the name of the textbox that I want to specifically check the value of.
0
 
LVL 12

Accepted Solution

by:
Paurths earned 200 total points
ID: 6879685
my mistake,

i missed the 'continuous form' part...

is SBSP also the name of the field in your table?

cmdLoopTXT_Click()
Dim rst As Recordset

    Set rst = Me.RecordsetClone
   
    rst.MoveFirst
    While Not rst.EOF
        MsgBox rst!SBSP
    rst.MoveNext
    Wend
       
    rst.Close
    Set rst = Nothing
end sub
0
 

Author Comment

by:DSE
ID: 6879702
Thanks a lot Paurths,

It worked great first time without changing a thing!

Thanks again,

David.

0

Featured Post

 [eBook] Windows Nano Server

Download this FREE eBook and learn all you need to get started with Windows Nano Server, including deployment options, remote management
and troubleshooting tips and tricks

Question has a verified solution.

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

Did you know that more than 4 billion data records have been recorded as lost or stolen since 2013? It was a staggering number brought to our attention during last week’s ManageEngine webinar, where attendees received a comprehensive look at the ma…
This article shows how to get a list of available printers for display in a drop-down list, and then to use the selected printer to print an Access report or a Word document filled with Access data, using different syntax as needed for working with …
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
Suggested Courses

877 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