Results 1 to 2 of 2
  1. #1
    3 Star Lounger
    Join Date
    Jan 2001
    Thanked 0 Times in 0 Posts

    refreshing a form (Access 2000)

    I use the code below on a search form in my db. The fields are unbound. I have a button on the form which uses the code below to clear all the data someone may have in the fields. I have another button with code behind it that performs the search. The code works great , it clears all fields on the form, except that when the person tries to do another search they get no result. If they close the form and then go back in it works. Is there a way to add to the code below so that when the fields are cleared the form is some how requeried or refreshed? Not sure how to describe it. Thanks

    On Error GoTo cmdClear_Err
    Dim ctl As Control

    For Each ctl In Me.Controls
    If ctl.ControlType = acTextBox Or ctl.ControlType = acCheckBox Then
    ctl.Value = ""
    End If
    Next ctl

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Thanked 28 Times in 28 Posts

    Re: refreshing a form (Access 2000)

    We would need to know more about the search code to be able to understand what is happening, but try this first:

    For Each ctl In Me.Controls
    Select Case ctl.ControlType
    Case acTextBox
    ctl.Value = Null
    Case acCheckBox
    ctl.Value = False
    End Select
    Next ctl

    Instead of setting the value to an empty string, it is set to Null or False, depending on the control type.

Posting Permissions

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