General discussion

Locked

VB6

By iradalys ·
How do I write the code for a Loop that:
1. Opens a database
2. uses a timer object of 10 secs
3. checks if the DB has been updated (date)
4. checks for duplicate numbers using SQL
5. if yes uses msgbox

This conversation is currently closed to new comments.

7 total posts (Page 1 of 1)  
| Thread display: Collapse - | Expand +

All Comments

Collapse -

VB6

by andrew In reply to VB6

Here's a brief example:

Private Sub Form_Load()
Timer1.Interval = 10000 '10 seconds
Timer1.Enabled = True
End Sub

Private Sub Timer1_Timer()
Dim oCon As ADODB.Connection
Dim oRs As ADODB.Recordset
Static LastUpdate As DateSet oCon = New ADODB.Connection
oCon.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\WINNT\Profiles\awilliams\Desktop\avg.mdb;"
Set oRs = New Recordset
oRs.Open "SELECT LastUpdated FROM Table3", oCon
If oRs.Fields("LastUpdated").Value > LastUpdated Then
MsgBox "Data has been updated!"
LastUpdated = oRs.Fields("LastUpdated").Value 'cache the vlaue for the next check
End If

oRs.Close
Set oRs = Nothing
Set oCon = Nothing
End Sub

Collapse -

VB6

by iradalys In reply to VB6

Poster rated this answer

Collapse -

VB6

by andrew In reply to VB6

For detecting duplicate values, you can use a query like:

SELECT Distinct Data1 from Table3

If this returns more than 1 row (you can use the Recordset.Rowcount property) there are duplicates in the field you specified (Data1 in this example)

Collapse -

VB6

by iradalys In reply to VB6

Poster rated this answer

Collapse -

VB6

by mark.thomson In reply to VB6

to check for duplicates using SQL use a query something like this

SELECT Count(number) AS CountOfnumber
FROM table1
GROUP BY table1.number
HAVING (((Count(table1.number))>1))

Collapse -

VB6

by iradalys In reply to VB6

Poster rated this answer

Collapse -

VB6

by iradalys In reply to VB6

This question was closed by the author

Back to Web Development Forum
7 total posts (Page 1 of 1)  

Related Discussions

Related Forums