R
Ryan
I have a form with this on load event. "AllBalancesByFCandDBPD" is a
crosstab query.
Private Sub Form_Load()
Me.OrderBy = ""
Me.OrderByOn = False
Dim rst As Recordset
Dim db As Database
Dim q As QueryDef
Dim i As Integer
Dim j As Integer
Set db = CurrentDb
Set qdf = db.QueryDefs("AllBalancesByFCandDBPD")
For Each prm In qdf.Parameters
prm.Value = Eval(prm.Name)
Next prm
Set rst = qdf.OpenRecordset()
rst.MoveFirst
j = -1
i = 0
For i = 0 To rst.Fields.Count - 1
If rst.Fields(i).Name Like "*Financial Class" Then GoTo skip_it
j = j + 1
Select Case j
Case 0
Me.lbl1.Caption = rst.Fields(i).Name
Me.frmFCDBTotal.ControlSource = rst.Fields(i).Name
Case 1
Me.lbl2.Caption = rst.Fields(i).Name
Me.DB1.ControlSource = rst.Fields(i).Name
Case 2
Me.lbl3.Caption = rst.Fields(i).Name
Me.DB2.ControlSource = rst.Fields(i).Name
Case 3
Me.lbl4.Caption = rst.Fields(i).Name
Me.DB3.ControlSource = rst.Fields(i).Name
End Select
skip_it:
Next i
rst.Close
Set rst = Nothing
If Len(Me.lbl3.Caption) < 2 Then
Me.lbl3.Visible = False
Me.DB2.Visible = False
End If
If Len(Me.lbl4.Caption) < 2 Then
Me.lbl4.Visible = False
Me.DB3.Visible = False
End If
End Sub
Since a column my exist one time and not the next time, if a user right
clicks and sorts a-z or z-a on a column named C28, and then closes and opens
the form again and the results dont include a column named C28 I get this
error.
Run-time error '3070'
The Microsoft Jet database engine does not recognize " as a valid field name
or expression.
If I go into the form in design view, I see that the Order By propert is set
to AllBalancesByFCandDBPD.C28 DESC
No matter how I try, the only way to get rid of the value in the Order By
property is to open the form in design view and manually delete it. I have
tried these options
OnOpen and OnLoad events
Me.Orderby = ""
Me.Orderbyon = False
AND
Me.Form.Orderby = ""
Me.Form.Orderbyon = False
AND
Me.ControlSource.Oderby = ""
Me.ControlSource.Oderbyon = False
Please help!!!!
crosstab query.
Private Sub Form_Load()
Me.OrderBy = ""
Me.OrderByOn = False
Dim rst As Recordset
Dim db As Database
Dim q As QueryDef
Dim i As Integer
Dim j As Integer
Set db = CurrentDb
Set qdf = db.QueryDefs("AllBalancesByFCandDBPD")
For Each prm In qdf.Parameters
prm.Value = Eval(prm.Name)
Next prm
Set rst = qdf.OpenRecordset()
rst.MoveFirst
j = -1
i = 0
For i = 0 To rst.Fields.Count - 1
If rst.Fields(i).Name Like "*Financial Class" Then GoTo skip_it
j = j + 1
Select Case j
Case 0
Me.lbl1.Caption = rst.Fields(i).Name
Me.frmFCDBTotal.ControlSource = rst.Fields(i).Name
Case 1
Me.lbl2.Caption = rst.Fields(i).Name
Me.DB1.ControlSource = rst.Fields(i).Name
Case 2
Me.lbl3.Caption = rst.Fields(i).Name
Me.DB2.ControlSource = rst.Fields(i).Name
Case 3
Me.lbl4.Caption = rst.Fields(i).Name
Me.DB3.ControlSource = rst.Fields(i).Name
End Select
skip_it:
Next i
rst.Close
Set rst = Nothing
If Len(Me.lbl3.Caption) < 2 Then
Me.lbl3.Visible = False
Me.DB2.Visible = False
End If
If Len(Me.lbl4.Caption) < 2 Then
Me.lbl4.Visible = False
Me.DB3.Visible = False
End If
End Sub
Since a column my exist one time and not the next time, if a user right
clicks and sorts a-z or z-a on a column named C28, and then closes and opens
the form again and the results dont include a column named C28 I get this
error.
Run-time error '3070'
The Microsoft Jet database engine does not recognize " as a valid field name
or expression.
If I go into the form in design view, I see that the Order By propert is set
to AllBalancesByFCandDBPD.C28 DESC
No matter how I try, the only way to get rid of the value in the Order By
property is to open the form in design view and manually delete it. I have
tried these options
OnOpen and OnLoad events
Me.Orderby = ""
Me.Orderbyon = False
AND
Me.Form.Orderby = ""
Me.Form.Orderbyon = False
AND
Me.ControlSource.Oderby = ""
Me.ControlSource.Oderbyon = False
Please help!!!!