Solved

Loop through elements of a continuous form

Posted on 2002-03-19
5
1,057 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 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

Backup Your Microsoft Windows Server®

Backup all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Join & Write a Comment

In Debugging – Part 1, you learned the basics of the debugging process. You learned how to avoid bugs, as well as how to utilize the Immediate window in the debugging process. This article takes things to the next level by showing you how you can us…
Introduction When developing Access applications, often we need to know whether an object exists.  This article presents a quick and reliable routine to determine if an object exists without that object being opened. If you wanted to inspect/ite…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

747 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now