Private Sub Command1_Click()
Dim strSQL As String
Set conn = New ADODB.Connection
Set rs = New ADODB.Recordset
With conn
If .State = adStateOpen Then .Close
.Provider = "Microsoft.JET.OLEDB.4.0"
.ConnectionString = App.Path & "\data.mdb"
.Open
End With
If rs.State = adStateOpen Then rs.Close
strSQL = "select * from history"
rs.Open strSQL, conn, adOpenKeyset, adLockOptimistic
Set DataGrid1.DataSource = rs
End Sub
Dim str As String
Set rs = New ADODB.Recordset
str = " Select Query "
With rs
.ActiveConnection = con1
.CursorLocation = adUseClient
.CursorType = adOpenStatic
.LockType = adLockOptimistic
.Open str
End With
If Not rs.EOF Then
Set DataGrid.DataSource = rs
DataGrid.Refresh
Else
MsgBox "No Records Found in DataGrid!"
End If
Public cn As ADODB.Connection
Public RS As ADODB.Recordset
Sub fillcombo()
Set RS = New ADODB.Recordset
Set cn = New ADODB.Connection
cn.ConnectionString = "Provider = Microsoft.Jet.OLEDB.4.0;Data Source= " & (App.Path & "\time3.mdb") & "; persist security info = false"
cn.Open
RS.Open "select * from Table1 ", cn, adOpenStatic, adLockPessimistic
'RS.Requery
While RS.EOF = False
Combo1.AddItem RS!DateNow
RS.MoveNext
Wend
RS.Close
Set RS = Nothing
End Sub
Private Sub Combo1_Click()
Set cn = New ADODB.Connection
Set RS = New ADODB.Recordset
cn.ConnectionString = "Provider = Microsoft.Jet.OLEDB.4.0;Data Source= " & (App.Path & "\time3.mdb") & "; persist security info = false"
cn.Open
RS.Open "select * from Table1 where DateNow = '" & Combo1.Text & "'", cn, 3, 3
If Not RS.EOF Then
Me.Combo1.Text = RS!DateNow
End If
Set RS = Nothing
End Sub
Private Sub Command3_Click()
Dim find As String
find = Combo1.Text
Adodc1.Recordset.find "DateNow =" & find
End Sub
Private Sub DataGrid1_Click()
Set cn = New ADODB.Connection
Set RS = New ADODB.Recordset
cn.ConnectionString = "Provider = Microsoft.Jet.OLEDB.4.0;Data Source= " & (App.Path & "\time3.mdb") & "; persist security info = false"
cn.Open
RS.Open "select * from Table1 where DateNow = '" & Combo1.Text & "'", cn, 3, 3
End Sub
Private Sub Form_Load()
Me.fillcombo
End Sub