[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

If statement causes for next loop to exit

Posted on 2014-03-20
4
Medium Priority
?
127 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

Ask an Anonymous Question!

Don't feel intimidated by what you don't know. Ask your question anonymously. It's easy! Learn more and upgrade.

Question has a verified solution.

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

After several hours of googling I could not gather any information on this topic. There are several ways of controlling the USB port connected to any storage device. The best example of that is by changing the registry value of "HKEY_LOCAL_MACHINE\S…
Entering time in Microsoft Access can be difficult. An input mask often bothers users more than helping them and won't catch all typing errors. This article shows how to create a textbox for 24-hour time input with full validation politely catching …
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 is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.

649 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