PDA

Click to See Complete Forum and Search --> : problem using Datagrid with code


Ta
Feb 13th, 2000, 03:25 PM
The following is my code. The problem I encountered is the error message will be shown as error # 7004 which indicate Dtagrid
can not be bookmarked.

But I can use "set" method to set up the value of textbox. It didn't work when appling to the Datagrid control.


General_Declaration()
Dim con As ADODB.Connection
Dim rec As ADODB.Recordset


Private Sub Form_Load()
Set con = New ADODB.Connection
Set rec = New ADODB.Recordset

con.Open "DSN=pubs;UID=edwardchung;PWD=;"
rec.Open "select * from titles", con

If con.State = adStateOpen Then
MsgBox "welcome"
Else
MsgBox " No connection "
End If
End Sub

Private Sub Command1_Click()

Set Text1.DataSource = rec
Text1.DataField = "title_id"

Set DataGrid1.DataSource = rec <-----Problem
End Sub