hey guys i have the following code for a crosstab report which all runs ok just extremley slow (like 2 mins) to open where as the query the reports is based on takes only about 10 seconds listed below is my code for that report any suggestions would be appreciated.
Option Compare Database
Option Explicit
Private Sub Report_Load()
Dim rst As DAO.Recordset
Dim db As DAO.Database
Dim i As Integer
Dim j As Integer
Set db = CurrentDb
Set rst = db.OpenRecordset("Select * From crstabSTOCK")
rst.MoveFirst
j = -1
i = 0
For i = 0 To rst.Fields.Count - 1
If rst.Fields(i).Name Like "ISDP_DESC" Then GoTo skip_it
j = j + 1
Select Case j
Case 0
Me.lbl0.Caption = rst.Fields(i).Name
Case 1
Me.lbl1.Caption = rst.Fields(i).Name
Case 2
Me.lbl2.Caption = rst.Fields(i).Name
Case 3
Me.lbl3.Caption = rst.Fields(i).Name
Case 4
Me.lbl4.Caption = rst.Fields(i).Name
Case 5
Me.lbl5.Caption = rst.Fields(i).Name
Case 6
Me.lbl6.Caption = rst.Fields(i).Name
End Select
skip_it:
Next
rst.Close
Set rst = Nothing
End Sub
Private Sub Report_Open(Cancel As Integer)
Dim rst As DAO.Recordset
Dim db As DAO.Database
Dim i As Integer
Dim j As Integer
Set db = CurrentDb
Set rst = db.OpenRecordset("Select * From crstabSTOCK")
rst.MoveFirst
j = -1
i = 0
For i = 0 To rst.Fields.Count - 1
If rst.Fields(i).Name Like "ISDP_DESC" Then GoTo skip_it
j = j + 1
Select Case j
Case 0
Me.txt0.ControlSource = rst.Fields(i).Name
Case 1
Me.txt1.ControlSource = rst.Fields(i).Name
Case 2
Me.txt2.ControlSource = rst.Fields(i).Name
Case 3
Me.txt3.ControlSource = rst.Fields(i).Name
Case 4
Me.txt4.ControlSource = rst.Fields(i).Name
Case 5
Me.txt5.ControlSource = rst.Fields(i).Name
Case 6
Me.txt6.ControlSource = rst.Fields(i).Name
End Select
skip_it:
Next i
rst.Close
Set rst = Nothing
End Sub
Option Compare Database
Option Explicit
Private Sub Report_Load()
Dim rst As DAO.Recordset
Dim db As DAO.Database
Dim i As Integer
Dim j As Integer
Set db = CurrentDb
Set rst = db.OpenRecordset("Select * From crstabSTOCK")
rst.MoveFirst
j = -1
i = 0
For i = 0 To rst.Fields.Count - 1
If rst.Fields(i).Name Like "ISDP_DESC" Then GoTo skip_it
j = j + 1
Select Case j
Case 0
Me.lbl0.Caption = rst.Fields(i).Name
Case 1
Me.lbl1.Caption = rst.Fields(i).Name
Case 2
Me.lbl2.Caption = rst.Fields(i).Name
Case 3
Me.lbl3.Caption = rst.Fields(i).Name
Case 4
Me.lbl4.Caption = rst.Fields(i).Name
Case 5
Me.lbl5.Caption = rst.Fields(i).Name
Case 6
Me.lbl6.Caption = rst.Fields(i).Name
End Select
skip_it:
Next
rst.Close
Set rst = Nothing
End Sub
Private Sub Report_Open(Cancel As Integer)
Dim rst As DAO.Recordset
Dim db As DAO.Database
Dim i As Integer
Dim j As Integer
Set db = CurrentDb
Set rst = db.OpenRecordset("Select * From crstabSTOCK")
rst.MoveFirst
j = -1
i = 0
For i = 0 To rst.Fields.Count - 1
If rst.Fields(i).Name Like "ISDP_DESC" Then GoTo skip_it
j = j + 1
Select Case j
Case 0
Me.txt0.ControlSource = rst.Fields(i).Name
Case 1
Me.txt1.ControlSource = rst.Fields(i).Name
Case 2
Me.txt2.ControlSource = rst.Fields(i).Name
Case 3
Me.txt3.ControlSource = rst.Fields(i).Name
Case 4
Me.txt4.ControlSource = rst.Fields(i).Name
Case 5
Me.txt5.ControlSource = rst.Fields(i).Name
Case 6
Me.txt6.ControlSource = rst.Fields(i).Name
End Select
skip_it:
Next i
rst.Close
Set rst = Nothing
End Sub