Hi,
I'm new to VB. I need to know how to get data into a data grid. I have a form where the user enters a range of dates. I'm using an SQL statement to find the records. How do I set the datamember to a new command. I need to do this at run time not design time.
the code I have is as follows:
Dim WithEvents cnhbook As Connection
Dim rshbook As Recordset
Dim cmd1 As Command
Private Sub cmdrsrch_Click()
Set cnhbook = New Connection
Set rshbook = New Recordset
Set cmd1 = New Command
With cnhbook
.Provider = "Microsoft.Jet.OLEDB.4.0"
.ConnectionString = "data source = d:\theresa\hist\books.mdb"
.Open
End With
Set cmd1.ActiveConnection = cnhbook
cmd1.CommandText = "select * from books where cdate(bdate)>='" & txtstdt & "' and cdate(bdate)<='" & txtenddt & "'"
cmd1.CommandType = adCmdText
Set rshbook = cmd1.Execute
now what do I do?????
Any help would be apprecitated!!
Thanks.. Theresa
I'm new to VB. I need to know how to get data into a data grid. I have a form where the user enters a range of dates. I'm using an SQL statement to find the records. How do I set the datamember to a new command. I need to do this at run time not design time.
the code I have is as follows:
Dim WithEvents cnhbook As Connection
Dim rshbook As Recordset
Dim cmd1 As Command
Private Sub cmdrsrch_Click()
Set cnhbook = New Connection
Set rshbook = New Recordset
Set cmd1 = New Command
With cnhbook
.Provider = "Microsoft.Jet.OLEDB.4.0"
.ConnectionString = "data source = d:\theresa\hist\books.mdb"
.Open
End With
Set cmd1.ActiveConnection = cnhbook
cmd1.CommandText = "select * from books where cdate(bdate)>='" & txtstdt & "' and cdate(bdate)<='" & txtenddt & "'"
cmd1.CommandType = adCmdText
Set rshbook = cmd1.Execute
now what do I do?????
Any help would be apprecitated!!
Thanks.. Theresa