RAYMOND HJ
10-25-2000, 08:21 AM
My problem is, I got a runtime error "Object variable or with block variable not set".
I'm using Acess and data control to connect to database as below:-
Option Explicit
Dim intRow As Integer
Private Sub Form_Load()
Data1.RecordSource = "SELECT * FROM Treatment WHERE Patient_Id = 4"
Msflexgrid1.Clear
Msflexgrid1.Row = 0
Msflexgrid1.Col = 0
Msflexgrid1.Text = "No."
Msflexgrid1.ColWidth(0) = 500
Msflexgrid1.FixedAlignment(0) = vbCenter
Msflexgrid1.Col = 1
Msflexgrid1.Text = "Name"
Msflexgrid1.ColWidth(1) = 1000
Msflexgrid1.FixedAlignment(1) = vbLeftJustify
intRow = 1
Do While Data1.Recordset!Patient_Id = 4 'this line error
Msflexgrid1.Row = intRow
Msflexgrid1.Col = 0
Msflexgrid1.Text = intRow
Msflexgrid1.Col = 1
Msflexgrid1.Text = Data1.Recordset!Name
intRow = intRow + 1
Data1.Recordset.MoveNext
If Data1.Recordset.EOF Then
Exit Sub
End If
Loop
End Sub
Thanks for any idea to solve this problem...
I'm using Acess and data control to connect to database as below:-
Option Explicit
Dim intRow As Integer
Private Sub Form_Load()
Data1.RecordSource = "SELECT * FROM Treatment WHERE Patient_Id = 4"
Msflexgrid1.Clear
Msflexgrid1.Row = 0
Msflexgrid1.Col = 0
Msflexgrid1.Text = "No."
Msflexgrid1.ColWidth(0) = 500
Msflexgrid1.FixedAlignment(0) = vbCenter
Msflexgrid1.Col = 1
Msflexgrid1.Text = "Name"
Msflexgrid1.ColWidth(1) = 1000
Msflexgrid1.FixedAlignment(1) = vbLeftJustify
intRow = 1
Do While Data1.Recordset!Patient_Id = 4 'this line error
Msflexgrid1.Row = intRow
Msflexgrid1.Col = 0
Msflexgrid1.Text = intRow
Msflexgrid1.Col = 1
Msflexgrid1.Text = Data1.Recordset!Name
intRow = intRow + 1
Data1.Recordset.MoveNext
If Data1.Recordset.EOF Then
Exit Sub
End If
Loop
End Sub
Thanks for any idea to solve this problem...