Solved

Loop through elements of a continuous form

Posted on 2002-03-19
5
1,152 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
[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
  • 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 50 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

Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

Question has a verified solution.

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

Overview: This article:       (a) explains one principle method to cross-reference invoice items in Quickbooks®       (b) explores the reasons one might need to cross-reference invoice items       (c) provides a sample process for creating a M…
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…
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…

751 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