Public i As Integer
Public CON As New Connection
Private Sub Command1_Click()
Set CON = New Connection
CON.Open "Provider=Microsoft.Jet.OLEDB.4.0;data source=" & App.Path & "\" & "TimeStamp.mdb"
Dim rs As New Recordset
rs.Open "Select * from MilliSeconds", CON, adOpenKeyset, adLockOptimistic
rs.AddNew
rs![MilliSec] = Label2.Caption
rs.Update
rs.Close
End Sub
Private Sub Command2_Click()
With TChart1.Series(0)
' remove previous existing points from the Series
.Clear
' add new points to the Series...
' .Add 100, "Europe", vbRed
' .Add 300, "USA", vbBlue
' .Add 200, "Asia", vbGreen
' .Add 120, "Australia", vbYellow
End With
'End Sub
End Sub
Private Sub Command3_Click()
TChart1.Series(0).CheckDataSource
' add new points to the Series...
' .Add 100, "Europe", vbRed
' .Add 300, "USA", vbBlue
' .Add 200, "Asia", vbGreen
' .Add 120, "Australia", vbYellow
' End With
'End Sub
End Sub
Private Sub Form_Terminate()
'MsgBox "Thanks for using.", , "Thanks"
End Sub
Private Sub Timer1_Timer()
Timer1.Interval = 1
Label2.Caption = Format(Time, "hh:mm:ss")
'+ ":" + Label1.Caption
'''Label1.Caption = Val(Label1.Caption) + 1
'''If Label1.Caption = 100 Then
'''Label1.Caption = 1
'End If
Call run1
Call run
Set CON = New Connection
CON.Open "Provider=Microsoft.Jet.OLEDB.4.0;data source=" & App.Path & "\" & "TimeStamp.mdb"
Dim rs As New Recordset
rs.Open "Select * from MilliSeconds", CON, adOpenKeyset, adLockOptimistic
rs.AddNew
rs![MilliSec] = Label2.Caption
rs.Fields(1) = sec.Caption
rs.Update
rs.Close
End Sub
Public Sub run1()
If i = 10000 Then
i = 0
Else
i = i + Timer1.Interval
End If
End Sub
Public Sub run()
sec.Caption = i
End Sub
Here is the code I am using. I want to update the teechart as the values are being populated in the mdb file. So that the graph is running realtime but with values from the database. Please help have uploaded the project in the public attchments folder..
Samir
update chart from a database
Hi Samir,
you will have to use similar code as in the following one :
you will have to use similar code as in the following one :
Code: Select all
Dim Data As New ADODB.Connection
Dim rst As New ADODB.Recordset
Private Sub Form_Load()
Data.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" _
& App.Path & "\AccessTestDB.mdb;Persist Security Info=False"
rst.Open "select * from DataTwo", Data, 1, 1
With TChart1
.Aspect.View3D = False
.AddSeries scHorizBar
.Series(0).DataSource = rst
.Series(0).XValues.ValueSource = rst.Fields(1).Name
.Series(0).YValues.ValueSource = rst.Fields(2).Name
.Series(0).YValues.DateTime = True
End With
End Sub
Private Sub Timer1_Timer()
UpdateRecordSet
TChart1.Series(0).DataSource = rst
End Sub
Private Sub UpdateRecordSet()
Data.Close
Data.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" _
& App.Path & "\AccessTestDB.mdb;Persist Security Info=False"
rst.Open "select * from DataTwo", Data, 1, 1
End Sub
Pep Jorge
http://support.steema.com
http://support.steema.com
Hi Samir,
I've modified your example and post it again into the attachments newsgroup.
I've modified your example and post it again into the attachments newsgroup.
Pep Jorge
http://support.steema.com
http://support.steema.com