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

    Loop through row source in combo box

    I'd like to loop through a combo box and for every id run a task

    so if combo box = 5 then open report, save as pdf, close etc

    Can anyone tell me how to loop through a combo box row source?

  2. #2
    Ruegen's Avatar
    Ruegen is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2013
    Location
    Australia
    Posts
    1,496
    Nevermind I used:

    Code:
    Dim strSql As String
    
    
        Dim intComboItem As Integer
        Dim MyPDFPath As String
        For intComboItem = 0 To Me.CboArea.ListCount - 1
           
            
    
    
    
    
    strSql = "SELECT tblShows.ID, tblShows.ShowName, tblShows.Blurb, tblShowTour.DateTouringFrom, tblShowTour.DateTouringUntil, tblShowTour.TypeID, tblShowTour.AreasID, tblShowTour.YearID " & vbCrLf & _
    "FROM tblYear INNER JOIN (tblType INNER JOIN (tblTerms INNER JOIN (tblStates INNER JOIN (tblShows INNER JOIN (tblAreas INNER JOIN tblShowTour ON tblAreas.ID = tblShowTour.AreasID) ON tblShows.ID = tblShowTour.ShowsID) ON tblStates.ID = tblAreas.StatesID) ON tblTerms.ID = tblShowTour.TermsID) ON tblType.ID = tblShowTour.TypeID) ON tblYear.ID = tblShowTour.YearID " & vbCrLf & _
    "WHERE (((tblShowTour.TypeID)=[Forms]![frmOrganiser]![CboType]) AND ((tblShowTour.AreasID)=" & Me.CboArea.ItemData(intComboItem) & ") AND ((tblShowTour.YearID)=[forms]![frmOrganiser]![CboYear]));"
    
    
        
        
    'makes a temp folder
     If Dir("C:\PDF Areas", vbDirectory) = "" Then
            MkDir ("C:\PDF Areas")
        End If
    
    
    
    
    DoCmd.OpenReport "rptPrintOut", acViewPreview, strSql, "", acNormal
    DoCmd.SelectObject acReport, "rptPrintOut"
    MyPDFPath = "C:\PDF Areas\" & Reports!rptPrintOut.Caption & ".pdf"
    DoCmd.OutputTo acOutputReport, "", acFormatPDF, MyPDFPath, False
    DoCmd.Close acReport, "rptPrintOut"
    '
            
            
            
        Next

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

Similar Threads

  1. Combo Box Row source problem
    By nbdwt73 in forum Access
    Replies: 2
    Last Post: 02-09-2014, 07:41 PM
  2. Replies: 1
    Last Post: 11-28-2013, 10:03 PM
  3. Replies: 8
    Last Post: 09-19-2013, 03:07 PM
  4. row source for a combo box
    By crowegreg in forum Forms
    Replies: 1
    Last Post: 02-05-2013, 05:18 PM
  5. Replies: 3
    Last Post: 12-11-2012, 09:12 AM

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