Results 1 to 7 of 7
  1. #1
    Silver Lounger
    Join Date
    Jun 2001
    Location
    Niagara Falls, New York, USA
    Posts
    1,878
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Can I Requery Datasheet Form From VB? (a2k (9.0.6926) SP-3 Jet 4.0 SP-7)

    I have the following VB code that reads periodic phone modem transmissions and adds records to an Access Database.

    There are approximately 20 records per day.

    The operator has an Access datasheet form to view these records.

    There is a Refresh button (Me.Form.Requery) on the datasheet form that the operator presses periodically to refresh the form and display any new records that the VB program may have added to the table since the last refresh..

    All the above works OK except for the undesired manual form refresh.

    Is there a way in the VB program and/or Access DB that I can refresh the Access DB datasheet form after each transmission?

    Thanks, John

    ========================
    Sub writerec()

    Dim sqltext As String
    Dim i As Integer
    Dim filename As String
    Dim Length As Integer
    Dim rst As Recordset
    On Error GoTo End_UpdateAccess

    '*
    '*-- Create Applicable records into access database.
    '*
    Set dbs = OpenDatabase(dbname)

    Set rst = dbs.OpenRecordset("nfalls")
    With rst
    .AddNew
    .Fields!ticket = Trim(ticket)
    .Fields!Date = Format(xmitdate, "Short date")
    .Fields!time1 = Format(time1, "Short time")
    .Fields!oper = oper
    .Fields!revticket = revticket

    .Fields!email = email
    .Fields![Cell Phone] = cellphone
    .Fields![Request To] = reqto
    .Fields!page = CInt(page)
    .Fields![Pager Number] = pager
    .Fields![Done By] = doneby
    .Fields!completed = False
    .Fields!TktTypPriority = TTPriority(tkttype)
    DoEvents
    .Update
    .Close
    End With
    DoEvents
    DisplayLog "U", " " + ticket + " Errors: " + Str(ProcessErrors)

    dbs.Close

    ResetWorkFields

    Exit Sub
    End_UpdateAccess:
    g = Err.Description
    t = Err.Source
    e = Err.Number
    ProcessErrors = ProcessErrors + 1
    'db_error (g)
    Resume Next
    End Sub

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Can I Requery Datasheet Form From VB? (a2k (9.0.6926) SP-3 Jet 4.0 SP-

    How would the Access database know that a phone transmission has taken place?

  3. #3
    Platinum Lounger
    Join Date
    Dec 2001
    Location
    Melbourne, Australia
    Posts
    4,594
    Thanks
    0
    Thanked 27 Times in 27 Posts

    Re: Can I Requery Datasheet Form From VB? (a2k (9.0.6926) SP-3 Jet 4.0 SP-

    Why not Requery the form on a timed basis using the Timer event of the form itself.

  4. #4
    Silver Lounger
    Join Date
    Jun 2001
    Location
    Niagara Falls, New York, USA
    Posts
    1,878
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Can I Requery Datasheet Form From VB? (a2k (9.0.6926) SP-3 Jet 4.0 SP-

    I'm guessing the VB program, after rst.Close could test to see if datasheet form is open,if open requery the form.

  5. #5
    Silver Lounger
    Join Date
    Jun 2001
    Location
    Niagara Falls, New York, USA
    Posts
    1,878
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Can I Requery Datasheet Form From VB? (a2k (9.0.6926) SP-3 Jet 4.0 SP-

    I thought of this as last resort, I guess I could test form for five minutes of inactitivy then issue requery

  6. #6
    Platinum Lounger
    Join Date
    Dec 2001
    Location
    Melbourne, Australia
    Posts
    4,594
    Thanks
    0
    Thanked 27 Times in 27 Posts

    Re: Can I Requery Datasheet Form From VB? (a2k (9.0.6926) SP-3 Jet 4.0 SP-

    What you could do also is to set a value in another table when the main table has been added to, then in the On Timer event test if this value has changed and if so then requery the form. Set your timer to one minute and your form will be up to date to a minute. If you wish it to be more up to date set your Timer Interval to say 30000 (30 seconds), but this is up to you.

  7. #7
    Silver Lounger
    Join Date
    Jun 2001
    Location
    Niagara Falls, New York, USA
    Posts
    1,878
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Can I Requery Datasheet Form From VB? (a2k (9.0.6926) SP-3 Jet 4.0 SP-

    (Very long piece of code moved to attachment by HansV. Preserves indentation too <img src=/S/grin.gif border=0 alt=grin width=15 height=15>)

    Hi Pat

    I ended up using Candace Tripp
    Attached Files Attached Files

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •