i need some help
i have a table with 5 city divisions
1 = D1
2 = D2
3 = D3
4 = D4
and
8 = D5
I am trying to write a For loop in within a while statement that will search not only 1 To 4, but also 8 as well. I have tried...For 1 To 4 Or 8 as code but that doesn't work. After my code reads the first 4 divisions it tries to read the integer 5, and i don't have a 5; i have an 8. I am using 5, 6, and 7 for other important things. How can I accomplish reading my 8 integer division in my tbl?
my code:
Public Function ExportPlanRepor ts(path As String)
Dim years As String
Dim dbo As Database
Dim records As Recordset
Dim sqlStatement As String
Dim i As Integer
sqlStatement = "SELECT tblPlanExtra.Ye ar FROM tblPlanExtra WHERE tblPlanExtra.Ye ar >= " & getPlanStarting Year & " GROUP BY tblPlanExtra.Ye ar ORDER BY tblPlanExtra.Ye ar;"
Set dbo = CurrentDb
Set records = dbo.OpenRecords et(sqlStatement )
While Not records.EOF
For i = 1 To 4
If isPlanLocked(re cords!Year, i) Then
Forms!frmMain!f rameDivision.va lue = i
DoCmd.OpenForm "frmPlan"
Forms!frmPlan!t xtYear.value = records!Year
DoCmd.OpenForm "frmPrintPl an"
PrintPlan
DoCmd.OutputTo acOutputReport, "rptPlan", "Snapshot Format", path & Forms!frmPlan!t xtYear.value & " " & FindDivisionNam e(Forms!frmMain !frameDivision. value) & ".snp"
DoCmd.Close acReport, "rptPlan"
DoCmd.Close acForm, "frmPrintPl an"
DoCmd.Close acForm, "frmPlan"
End If
Next i
records.MoveNex t
Wend
records.Close
End Function
thanks for your help in advance!!!
i have a table with 5 city divisions
1 = D1
2 = D2
3 = D3
4 = D4
and
8 = D5
I am trying to write a For loop in within a while statement that will search not only 1 To 4, but also 8 as well. I have tried...For 1 To 4 Or 8 as code but that doesn't work. After my code reads the first 4 divisions it tries to read the integer 5, and i don't have a 5; i have an 8. I am using 5, 6, and 7 for other important things. How can I accomplish reading my 8 integer division in my tbl?
my code:
Public Function ExportPlanRepor ts(path As String)
Dim years As String
Dim dbo As Database
Dim records As Recordset
Dim sqlStatement As String
Dim i As Integer
sqlStatement = "SELECT tblPlanExtra.Ye ar FROM tblPlanExtra WHERE tblPlanExtra.Ye ar >= " & getPlanStarting Year & " GROUP BY tblPlanExtra.Ye ar ORDER BY tblPlanExtra.Ye ar;"
Set dbo = CurrentDb
Set records = dbo.OpenRecords et(sqlStatement )
While Not records.EOF
For i = 1 To 4
If isPlanLocked(re cords!Year, i) Then
Forms!frmMain!f rameDivision.va lue = i
DoCmd.OpenForm "frmPlan"
Forms!frmPlan!t xtYear.value = records!Year
DoCmd.OpenForm "frmPrintPl an"
PrintPlan
DoCmd.OutputTo acOutputReport, "rptPlan", "Snapshot Format", path & Forms!frmPlan!t xtYear.value & " " & FindDivisionNam e(Forms!frmMain !frameDivision. value) & ".snp"
DoCmd.Close acReport, "rptPlan"
DoCmd.Close acForm, "frmPrintPl an"
DoCmd.Close acForm, "frmPlan"
End If
Next i
records.MoveNex t
Wend
records.Close
End Function
thanks for your help in advance!!!
Comment