tb :
It needs to be continuosly populated, because, it's a monitoring tool, which looks in a db, if any new posts has come, If any then repopulate listbox.
I'm populating it using, in test, access with ADO. Will be going on to MSSQL when the system is ready.
All the way through, it's a system which moniters Backup, Mail, Safety, and various other things, on remote computers..
WHen something happens, the server will send an email to me, and an Event sink in Exchange, will fill the data in the database. All in all.
Digsy :
Thnx for the code, at first when i inserted it, the program wouldn't show.. It didn't hang this time, but nothing showed.. So i tried with a Me.Show in Form_Load, Then it showed...
But now I have to push the close button 7 times hehe..
This is the full code :
[tt]
Public CallAgain As Boolean
Public Sub Delay(lngSeconds As Long)
Dim lngStart As Long
Dim intstart As Integer
lngStart = Timer
Do While Timer <= lngStart + lngSeconds
DoEvents
If CallAgain = False Then
Exit Do
End If
Loop
End Sub
Sub ListSager()
Dim i
Dim LBHS As New CLBHScroll
Dim MyConn As New ADODB.Connection
Dim RSSag As New ADODB.Recordset
Dim RSAntal As New ADODB.Recordset
Dim ConnString As String
ConnString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\DB\CS-SupportDB.mdb;User Id=admin;Password=;"
MyConn.ConnectionString = ConnString
MyConn.Open
' #### See if any new posts in db '
SQLFindAntalSagerQuery = "SELECT COUNT(*) As SagsAntal FROM SagsTB WHERE Afviklet = false"
Set RSAntal = MyConn.Execute(SQLFindAntalSagerQuery)
If RSAntal("SagsAntal") > lblSagsAntal.Caption Then
SQLFindSagsInfoQuery = "SELECT Sag.SagsId, Sag.Dato, Sup.SupportType, MedArb.Navne, Sag.ProblemBeskrivelse FROM SagsTB Sag, SupportTypeTB Sup, MedarbejderTB MedArb WHERE Sag.SupportId = Sup.SupportId AND Sag.MedarbejderId = MedArb.MedarbejderId AND Sag.Afviklet = false"
Set RSSag = MyConn.Execute(SQLFindSagsInfoQuery)
' #### LBHS is a listbox interface, which puts on scroll bars if nessecary '
LBHS.Init lstSagsList
Do While Not (RSSag.BOF Or RSSag.EOF)
LBHS.AddItemTab RSSag("SagsId") & _
vbTab & RSSag("Dato") & _
vbTab & RSSag("SupportType") & _
vbTab & RSSag("Navne") & _
vbTab & RSSag("ProblemBeskrivelse")
RSSag.MoveNext
Loop
lblSagsAntal.Caption = RSAntal("SagsAntal")
End If
MyConn.Close
Set MyConn = Nothing
Delay (5)
If CallAgain = True Then
ListSager
End If
End Sub
Private Sub Form_Load()
ReDim TabStops(3) As Long
' #### Make tabsstops in listbox '
TabStops(0) = 40
TabStops(1) = 125
TabStops(2) = 185
TabStops(3) = 240
Call SendMessage(lstSagsList.hwnd, LB_SETTABSTOPS, 4&, TabStops(0))
Me.Show
CallAgain = True
ListSager
End Sub
Private Sub Form_Unload(Cancel As Integer)
CallAgain = False
End Sub
Private Sub Form_Hide()
CallAgain = False
End Sub
[/tt]
I will try to find out why it's 7 times, i have to click..?
But if anyone can see it please let me know.. Thnx by the way, for the quick response.
Machine code Rocks