Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

continuous update of text boxes

rwheelerrwheeler Member Posts: 2
I need to continuously update text boxes on a form that receive their values from an opc/dde server. I have tried using the form timer event but though the values change properly the result is not as smooth as I would like it. The hourglass appears at each interval as the data is requeried and I need the data every second or so. I should have built the interface with VB but I did not and I cannot change now. I have been bringing the values int an excel spreadsheet and pasting the cells into my form. This works but again not the best answer I am sure. Does any one know if there is an active x control etc. that I could insert into my form that would streamline this data display problem.

Comments

  • splansingsplansing Member Posts: 140
    [b][red]This message was edited by splansing at 2005-10-25 12:6:44[/red][/b][hr]
    : I need to continuously update text boxes on a form that receive their values from an opc/dde server. I have tried using the form timer event but though the values change properly the result is not as smooth as I would like it. The hourglass appears at each interval as the data is requeried and I need the data every second or so. I should have built the interface with VB but I did not and I cannot change now. I have been bringing the values int an excel spreadsheet and pasting the cells into my form. This works but again not the best answer I am sure. Does any one know if there is an active x control etc. that I could insert into my form that would streamline this data display problem.
    :
    Maybe this will help, maybe not. I'm not sure about some of the things you mentioned. But you can use something like the following for your controlsource:

    =DLookup("DesiredFieldName","TableOrQueryName","WhereCondition")

    A bunch of these together will cause your form to open slowly initially, and there might be a bit of lag here and there. But I find it works pretty well if you don't overdo it. Look up the DLookup/DMin/DMax/DSum functions for more information.


  • aatkbdaatkbd Member Posts: 42
    : I need to continuously update text boxes on a form that receive their values from an opc/dde server. I have tried using the form timer event but though the values change properly the result is not as smooth as I would like it. The hourglass appears at each interval as the data is requeried and I need the data every second or so. I should have built the interface with VB but I did not and I cannot change now. I have been bringing the values int an excel spreadsheet and pasting the cells into my form. This works but again not the best answer I am sure. Does any one know if there is an active x control etc. that I could insert into my form that would streamline this data display problem.
    :


    [blue]
    Here is the class I use to run a query through ODBC and still allow user interaction. This code will only work with databases that allow asynchronous queries. After the recordset is returned then all you have to do is update the fields.

    [code]
    Option Compare Database
    Option Explicit

    Private wrkODBC As Workspace
    Private conPubs As Connection
    Private TimerStart As Single
    Private TimerEnd As Single
    Private msg As String
    Private QueryCancel As Boolean

    Private Sub Class_Initialize()
    On Error GoTo Err_Handler
    Set wrkODBC = CreateWorkspace("NewODBCWorkspace", _
    "admin", "", dbUseODBC)

    Set conPubs = wrkODBC.OpenConnection("Connection2", dbDriverComplete + dbRunAsync, True, _
    "ODBC;DSN=_____;UID=_______;PWD=_______;DBQ=______;")

    Do While conPubs.StillExecuting
    DoEvents
    Loop

    conPubs.QueryTimeout = 600
    QueryCancel = False
    DoEvents
    Err_Handler:
    If Err.Number <> 0 Then
    msg = "Error # " & Err.Number & " was generated by " _
    & Err.Source & vbNewLine & Err.Description & " Class: ODBCModule Function: Class_Initialize()"
    WriteToFile msg
    End If
    End Sub

    Private Sub Class_Terminate()
    On Error Resume Next
    conPubs.Close
    wrkODBC.Close
    End Sub

    Public Function Run_Query(SQL As String) As Recordset
    On Error GoTo Err_Handler
    Dim I As Integer
    Dim WaitTimer As Single

    If QueryCancel Then
    Set Run_Query = Nothing
    Else
    TimerStart = Timer
    Set Run_Query = conPubs.OpenRecordset(SQL, dbOpenSnapshot, dbRunAsync)
    SysCmd acSysCmdInitMeter, " ", 100
    I = 0
    WaitTimer = Timer
    Do While Run_Query.StillExecuting
    DoEvents
    If Timer - WaitTimer > 5 Then
    WaitTimer = Timer
    SysCmd acSysCmdUpdateMeter, I
    I = I + 1
    If I > 100 Then
    SysCmd acSysCmdInitMeter, " ", 100
    I = 0
    End If
    End If
    If QueryCancel Then
    Run_Query.Cancel
    Set Run_Query = Nothing
    End If
    Loop
    SysCmd acSysCmdRemoveMeter
    TimerEnd = Timer

    WriteToFile "Query ran for " & TimerEnd - TimerStart & " Seconds"
    If Run_Query.BOF And Run_Query.EOF Then
    Run_Query.Close
    Set Run_Query = Nothing
    End If
    End If

    Err_Handler:
    If Err.Number = 3420 Then
    msg = "Error # " & Err.Number & " was generated by " _
    & Err.Source & vbNewLine & Err.Description & " Class: ODBCModule Function: Run_Query(SQL As String)"
    WriteToFile "Invalid Recordset"
    WriteToFile msg
    Set Run_Query = Nothing
    ElseIf Err.Number = 3146 Then
    msg = "Error # " & Err.Number & " was generated by " _
    & Err.Source & vbNewLine & Err.Description & " Class: ODBCModule Function: Run_Query(SQL As String)"
    WriteToFile "ODBC Connection Problem"
    WriteToFile msg
    Err.Clear
    Set Run_Query = Nothing
    ElseIf Err.Number = 63535 Then
    msg = "Error # " & Err.Number & " was generated by " _
    & Err.Source & vbNewLine & Err.Description & " Class: ODBCModule Function: Run_Query(SQL As String)"
    WriteToFile "Query Timed Out"
    WriteToFile msg
    Set Run_Query = Nothing
    ElseIf Err.Number <> 0 Then
    msg = "Error # " & Err.Number & " was generated by " _
    & Err.Source & vbNewLine & Err.Description & " Class: ODBCModule Function: Run_Query(SQL As String)"
    WriteToFile msg
    Set Run_Query = Nothing
    End If
    End Function

    Public Property Let CancelQuery(Value As Boolean)
    QueryCancel = Value
    End Property
    [/code]
    [/blue]
  • HackmanCHackmanC Member Posts: 441
    [b][red]This message was edited by HackmanC at 2005-10-28 15:26:2[/red][/b][hr]
    I believed DDE was dead ! Ooops !
    From COM+ there was no need to DDE, COM provides better IPC.
    You can make an Object Type Excel ... etc..

    dim objExcel
    [code]
    function open()
    objExcel = new CreateObject("Microsoft.Excel.8...Check");
    ' objExcel = GetObject("Micros...");
    objExcel.Open ("C:FILE1.XLS");
    end function

    function refresh1()
    ' objExcel.Range("C7").Select
    ' TextBox1.Text = objExcel.ActiveCell.FormulaR1C1
    TextBox1.Text = objExcel.Cell(xxx);
    end function

    function close()
    objExcel.Close;
    end function
    [/code]
    Call the function refresh1 for "refresh"... Check the VBA Help in Excel or use the Object Viewer.

    -----
    : I need to continuously update text boxes on a form that receive their values from an opc/dde server. I have tried using the form timer event but though the values change properly the result is not as smooth as I would like it. The hourglass appears at each interval as the data is requeried and I need the data every second or so. I should have built the interface with VB but I did not and I cannot change now. I have been bringing the values int an excel spreadsheet and pasting the cells into my form. This works but again not the best answer I am sure. Does any one know if there is an active x control etc. that I could insert into my form that would streamline this data display problem.
    :

    [red]Good luck![/red]
    [blue]Hackman[/blue]



Sign In or Register to comment.