?
Solved

If statement causes for next loop to exit

Posted on 2014-03-20
4
Medium Priority
?
125 Views
Last Modified: 2014-08-25
Hello,

I have a for next loop interating over a collection of dataset rows,

I want to insert a couple of if statements to populate a couple of cells in the rows but I'm finding as soon as the first if statement is processed the for next loop is exited.

Am I missing something?

Thanks
0
Comment
Question by:Petermcg001
[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
  • 2
4 Comments
 
LVL 27

Expert Comment

by:MacroShadow
ID: 39942416
Probably a problem with your structure, if you show the code we can help.
0
 
LVL 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 39942463
which programming language exactly?
it must be an explicit "code" in your code to "break" to "exit" the loop, please post the relevant part of the code
0
 
LVL 1

Author Comment

by:Petermcg001
ID: 39942504
Thanks for looking at this,

My vb.net code is:-
For Each DeliveryTicketRow As dsDeliveryTickets.UnprintedTicketsRow In DsDeliveryTickets.UnprintedTickets
            AccountsTableAdapter.FillBy(DsAccounts.Accounts, DeliveryTicketRow.Account)
            Account = DsAccounts.Accounts(0)
            With DeliveryTicketRow
                .AccountAddress1 = Account.AddressLine1
                .AccountAddress2 = Account.AddressLine2
                .AccountAddress3 = Account.AddressLine3
                .AccountTown = Account.AddressLine4
                .AccountName = Account.CustomerAccountName
                .AccountPostcode = Account.PostCode
                .AccountTelephoneNumber = Account.TelephoneNumber
                If .StatusFlag = "U" Then .UrgentText = "Urgent"


                If .LineNote = "F" Then .FillText = "Fill"


            End With

        Next

Open in new window


As soon as the first if is processed the loop exits.
0
 
LVL 143

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 2000 total points
ID: 39949824
the code as such does not show anything that shall raise this issue.
so, either you have some (unhandled) error somewhere, OR it's the WITH statement structure which might give you that issue.
please try to run the code without the WITH, like this
For Each DeliveryTicketRow As dsDeliveryTickets.UnprintedTicketsRow In DsDeliveryTickets.UnprintedTickets
            AccountsTableAdapter.FillBy(DsAccounts.Accounts, DeliveryTicketRow.Account)
            Account = DsAccounts.Accounts(0)
            
                DeliveryTicketRow.AccountAddress1 = Account.AddressLine1
                DeliveryTicketRow.AccountAddress2 = Account.AddressLine2
                DeliveryTicketRow.AccountAddress3 = Account.AddressLine3
                DeliveryTicketRow.AccountTown = Account.AddressLine4
                DeliveryTicketRow.AccountName = Account.CustomerAccountName
                DeliveryTicketRow.AccountPostcode = Account.PostCode
                DeliveryTicketRow.AccountTelephoneNumber = Account.TelephoneNumber
                If DeliveryTicketRow.StatusFlag = "U" Then DeliveryTicketRow.UrgentText = "Urgent"


                If DeliveryTicketRow.LineNote = "F" Then DeliveryTicketRow.FillText = "Fill"

        Next

Open in new window

0

Featured Post

Visualize your virtual and backup environments

Create well-organized and polished visualizations of your virtual and backup environments when planning VMware vSphere, Microsoft Hyper-V or Veeam deployments. It helps you to gain better visibility and valuable business insights.

Question has a verified solution.

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

zlib is a free compression library (a DLL) on which the popular gzip utility is built.  In this article, we'll see how to use the zlib functions to compress and decompress data in memory; that is, without needing to use a temporary file.  We'll be c…
This article surveys and compares options for encoding and decoding base64 data.  It includes source code in C++ as well as examples of how to use standard Windows API functions for these tasks. We'll look at the algorithms — how encoding and decodi…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…

770 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