Scolling Text while Refreshing db

Diem

New member
Local time
Tomorrow, 06:42
Joined
Jun 26, 2003
Messages
9
Hi,

Hope someone can help me with this one...
I've got a form used as a scrolling text. On another form, I've got a button to activate a refresh of the database (by calling a function).

How do I have the scrolling text run while the refresh is being executed (this might take a while) and stop the scrolling text when the refresh is finished (confirmed by a pop up message).

Thanks in advance.
Dm
 
Diem,

What is the scrolling text and how do you refresh the
database?

Wayne
 
Hi Wayne,

Thanks for the prompt reply.

Here's my SCROLLING TEXT form:

Public txtScrollStatus As String

Private Sub Form_Load()

Me.lblScrollingLabel.Caption = "Patience is a Virtue ........................."

End Sub

Private Sub Form_Timer()

Me.lblScrollingLabel.Caption = Mid(Me.lblScrollingLabel.Caption, 2, _ (Len(Me.lblScrollingLabel.Caption) - 1)) & Left(Me.lblScrollingLabel.Caption, 1)

End Sub


And here's the FUNCTION TO REFRESH THE DB (got it from Ms Support Centre):

Function DoesTblExist(strTblName As String) As Boolean
On Error Resume Next
Dim db As Database, tbl As TableDef
Set db = CurrentDb
Set tbl = db.TableDefs(strTblName)
If Err.Number = 3265 Then ' Item not found.
DoesTblExist = False
Exit Function
End If
DoesTblExist = True
End Function

Function CreateODBCLinkedTables() As Boolean
On Error GoTo CreateODBCLinkedTables_Err
Dim strTblName As String, strConn As String
Dim db As Database, rs As Recordset, tbl As TableDef
' ---------------------------------------------
' Register ODBC database(s)
' ---------------------------------------------
Set db = CurrentDb
Set rs = db.OpenRecordset("tblODBCDataSources")
With rs
While Not .EOF
DBEngine.RegisterDatabase rs("DSN"), _
"SQL Server", _
True, _
"Description=VSS - " & rs("DataBase") & _
Chr(13) & "Server=" & rs("Server") & _
Chr(13) & "Database=" & rs("DataBase")
' ---------------------------------------------
' Link table
' ---------------------------------------------
strTblName = rs("LocalTableName")
strConn = "ODBC;"
strConn = strConn & "DSN=" & rs("DSN") & ";"
strConn = strConn & "APP=Microsoft Access;"
strConn = strConn & "DATABASE=" & rs("DataBase") & ";"
strConn = strConn & "UID=" & rs("UID") & ";"
strConn = strConn & "PWD=" & rs("PWD") & ";"
strConn = strConn & "TABLE=" & rs("ODBCTableName")
If (DoesTblExist(strTblName) = False) Then
Set tbl = db.CreateTableDef(strTblName, _
dbAttachSavePWD, rs("ODBCTableName"), _
strConn)
db.TableDefs.Append tbl
Else
Set tbl = db.TableDefs(strTblName)
tbl.Connect = strConn
tbl.RefreshLink
End If

rs.MoveNext
Wend
End With
CreateODBCLinkedTables = True
MsgBox "Refreshed ODBC Data Sources", vbInformation
CreateODBCLinkedTables_End:
Exit Function
CreateODBCLinkedTables_Err:
MsgBox Err.Description, vbCritical, "MyApp"
Resume CreateODBCLinkedTables_End
End Function
 
Diem,

You have got a lot of software here, but I see no problems.

Code:
Public txtScrollStatus As String 

'
' You have a label on some form and are assigning a value to it
'
Private Sub Form_Load() 
Me.lblScrollingLabel.Caption = "Patience is a Virtue ........................." 
End Sub 


'
' Every so often, you will chop off the first letter of the label and make it
' scroll
'
Private Sub Form_Timer() 
Me.lblScrollingLabel.Caption = Mid(Me.lblScrollingLabel.Caption, 2, _ (Len(Me.lblScrollingLabel.Caption) - 1)) & Left(Me.lblScrollingLabel.Caption, 1) 
End Sub 


And here's the FUNCTION TO REFRESH THE DB (got it from Ms Support Centre): 

'
' This function just checks to see if the table name passed to
' it exists.
'
Function DoesTblExist(strTblName As String) As Boolean 
On Error Resume Next 
Dim db As Database, tbl As TableDef 

Set db = CurrentDb 
Set tbl = db.TableDefs(strTblName) 
If Err.Number = 3265 Then ' Item not found. 
   DoesTblExist = False 
   Exit Function 
End If 
DoesTblExist = True 
End Function 


'
' This function will read the table tblODBCDataSources and establish a link
' to the tables that are named within it.  It will call the function above
' to check on the table.
'
Function CreateODBCLinkedTables() As Boolean 
On Error GoTo CreateODBCLinkedTables_Err 
Dim strTblName As String, strConn As String 
Dim db As Database, rs As Recordset, tbl As TableDef 
' --------------------------------------------- 
' Register ODBC database(s) 
' --------------------------------------------- 
Set db = CurrentDb 
Set rs = db.OpenRecordset("tblODBCDataSources") 
With rs 
   While Not .EOF 
      DBEngine.RegisterDatabase rs("DSN"), _ 
                                "SQL Server", _ 
                                True, _ 
                                "Description=VSS - " & rs("DataBase") & _ 
                                Chr(13) & "Server=" & rs("Server") & _ 
                                Chr(13) & "Database=" & rs("DataBase") 
   ' --------------------------------------------- 
   ' Link table 
   ' --------------------------------------------- 
   strTblName = rs("LocalTableName") 
   strConn = "ODBC;" 
   strConn = strConn & "DSN=" & rs("DSN") & ";" 
   strConn = strConn & "APP=Microsoft Access;" 
   strConn = strConn & "DATABASE=" & rs("DataBase") & ";" 
   strConn = strConn & "UID=" & rs("UID") & ";" 
   strConn = strConn & "PWD=" & rs("PWD") & ";" 
   strConn = strConn & "TABLE=" & rs("ODBCTableName") 
   If (DoesTblExist(strTblName) = False) Then 
      Set tbl = db.CreateTableDef(strTblName, _ 
          dbAttachSavePWD, rs("ODBCTableName"), _ 
          strConn) 
      db.TableDefs.Append tbl 
   Else 
      Set tbl = db.TableDefs(strTblName) 
      tbl.Connect = strConn 
      tbl.RefreshLink 
   End If 

   rs.MoveNext 
   Wend 
   End With 
CreateODBCLinkedTables = True 
MsgBox "Refreshed ODBC Data Sources", vbInformation 
CreateODBCLinkedTables_End: 
Exit Function 

CreateODBCLinkedTables_Err: 
MsgBox Err.Description, vbCritical, "MyApp" 
Resume CreateODBCLinkedTables_End 
End Function

What is the problem with it?

Wayne
 
Wayne,

There's no problem with the code. As I said, I've got another form in which I've got a button to execute the Refresh function. But I'd also like to have the scrolling text running at the same time (while the Refreshing function runs) so that the user gets an idea than the db is refreshing and not hanging (b/c it takes a while for the refresh to finish).

So basically, when activating the button, I'd like to have the scrolling text saying "Refreshing, please wait........" while the refreshing is being performed. The scrolling text should stop when the refreshing ends.

Does it make sense??
Thanks
Diem
 
Hi there,

No need to reply to this one. I actually found out why it can't be done.

Apparently, once the refresh has started it will take all the processor time, so the scrolling text won't be able to operate at the same time.

Thanks Wayne!
Dm
 

Users who are viewing this thread

Back
Top Bottom