PDA

Click to See Complete Forum and Search --> : Datagrid


deep
Oct 3rd, 2000, 09:05 AM
Hi,
I have a problem. I am using a datagrid with ADODC. I tried using it with a recordset object it did not work. This is my first problem.
The code that i have is:

Set rs1 = New ADODB.Recordset

strQuery2 = "select" & Chr(34) & "Control_No" & Chr(34) & ","
strQuery2 = strQuery2 & Chr(34) & "Check_In_Name" & Chr(34) & ","
strQuery2 = strQuery2 & Chr(34) & "Check_In_Description" & Chr(34)
strQuery2 = strQuery2 & " from Test_Carinrcdm where "
strQuery2 = strQuery2 & "Car_Number=" & txtCar_Number
'MsgBox strQuery2

rs1.Open strQuery2, cn2, adOpenKeyset, adLockOptimistic
MsgBox rs1("Control_No")
Set DataGrid1.DataSource = rs1

It gives me an error:
Runtime Error: 7004
Rowset not bookmarkable.

My second problem is:

when the records are displayed in the datagrid i do not want to let the user edit it. If i set the enable property to false, it disables the scroller also. I want the scroller to be enabled so that the user can scroll down and see all the records. Is there a way to get around it.

Please help...

P.S.W.
Oct 3rd, 2000, 12:06 PM
Well, your question about using an ADO recordset with the DataGrid is an often asked question around here, and I've personally never been able to make it work, nor have I ever seen a solution that works in practice. As far as I know, the Microsoft DataGrid is designed to work in conjunction with the Data Control only.

For your second problem, what you need to do is "lock" the columns of your datagrid instead of disabling the whole grid. You will have to lock each column separately, but this will prevent the user from being able to edit the data, while still retaining the scrolling & highlighting ability.

You can lock the columns from the property pages or use code like:

For i = 0 to 5
DataGrid1.Columns(i).Locked = True
Next i

Hope this helps!