Results 1 to 9 of 9
  1. #1
    Ruegen's Avatar
    Ruegen is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2013
    Location
    Australia
    Posts
    1,496

    For statement - skip value

    How do you skip a value if there is a condition in a for loop?

    for i = 0 to 8


    if i = 8 then

    move next (else it is at the end)

    end if


    next


  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,902
    I don't understand. Why do you need to test for 8?

    Move to Next what?
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    Ruegen's Avatar
    Ruegen is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2013
    Location
    Australia
    Posts
    1,496
    I have a combo box that I want to loop through until all rows in the combo box are cycled through

    however if one of the rows happens to have an id of say 8 - I want it to move on and not do the task for that row.

    problem also is that the row might be the final row so there wouldn't be anything to go next to... so I can't i = i + 1

  4. #4
    Ruegen's Avatar
    Ruegen is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2013
    Location
    Australia
    Posts
    1,496
    Quote Originally Posted by June7 View Post
    I don't understand. Why do you need to test for 8?

    Move to Next what?

    at the moment I can do this

    Function makeHTMLPDF(controlYear As Control, controlType As Control, controlState As Control, controlArea As Control, frm1 As String)




    For i = 0 To controlState.ListCount


    controlState = controlState.Column(0, i)


    If controlState.Column(0) <> 8 Then
    Debug.Print controlState.Column(1) & " keep "
    End If




    Next

    however I would prefer to skip if the value is 8

  5. #5
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,902
    Then I believe you are doing what must be done. Test if i is 8 and if it is, bypass code.

    Why are you picking on 8? What if the value of controlState is 21?
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  6. #6
    Ruegen's Avatar
    Ruegen is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2013
    Location
    Australia
    Posts
    1,496
    8 is a state that it skips as it has no records related to it (it's complicated)

    the code works fine thanks - however it relates to this problem

    https://www.accessforums.net/reports...ted-45495.html

    I still can't solve this one and it has to do with the report

  7. #7
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,902
    Can't solve what? That other thread says you fixed the issue.

    I've never seen code that loops through combobox rows.

    Also, why use a Function procedure if the function does not return a value? It's really a Sub procedure.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  8. #8
    Ruegen's Avatar
    Ruegen is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2013
    Location
    Australia
    Posts
    1,496
    Quote Originally Posted by June7 View Post
    Can't solve what? That other thread says you fixed the issue.

    I've never seen code that loops through combobox rows.

    Also, why use a Function procedure if the function does not return a value? It's really a Sub procedure.
    Yeah, I fixed it after some time after I posted the link.

    I found it easy to loop through combo boxes - it saves me having to make queries or sql strings and I can make it user customisable in the sense that they can choose what position they want to execute the code from when using the combo boxes.


    Yeah I probably should rename that function to a sub in the module...

  9. #9
    Ruegen's Avatar
    Ruegen is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2013
    Location
    Australia
    Posts
    1,496
    Might also say this database (one of two I work on) builds the company website to file. So the staff maintain the tour schedule through a front end and I update the server with the ready made html files made from the database.

    It's no Ruby on Rails (I'm using Access to build a website) but it's a quick solution for now and it works well there is a lot of information to have to put on the website and this database automates most of it

    I know there is PHP and SQL etc but I don't want to go down that track with this at the moment.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Skip a row number based on a value
    By rankhornjp in forum Access
    Replies: 2
    Last Post: 12-05-2011, 01:38 PM
  2. Skip a row number based on a value
    By rankhornjp in forum Reports
    Replies: 0
    Last Post: 12-05-2011, 01:37 PM
  3. Form Printing Skip.
    By cap.zadi in forum Forms
    Replies: 2
    Last Post: 11-28-2011, 10:41 PM
  4. Skip a line
    By Bear in forum Queries
    Replies: 13
    Last Post: 08-19-2011, 03:17 PM
  5. line skip in bookmarks
    By emilylu3 in forum Programming
    Replies: 0
    Last Post: 03-21-2006, 02:58 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums