Results 1 to 2 of 2
  1. #1
    Bronze Lounger
    Join Date
    Jan 2001
    Location
    Alzano Lombardo, Italy
    Posts
    1,483
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Date Search on a Form (2000)

    The Command51 button on the Prev form(please see attachment) allows me, once a date has been selected on the calendar, to display the record for that date as the first record on the form. Problem is, since I achieve this by filtering the form, I lose the visibility of all the records of an earlier date.
    How can I search for a date on the form and still be able to see all the records?
    Attached Files Attached Files

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

    Re: Date Search on a Form (2000)

    Instead of filtering the form, you can let the command button perform a search. The following code is derived from the code generated by the Combo Box Wizard if you specify the option to look up a record.

    Private Sub Command51_Click()
    Dim rst As Object

    On Error GoTo Err_Command51_Click

    Set rst = Me.Recordset.Clone
    rst.FindFirst "<!t>[Giorno]<!/t> >= #" & Format(Me!CGior, "mm/dd/yyyy") & "#"
    If Not rst.EOF Then Me.Bookmark = rst.Bookmark

    Exit_Command51_Click:
    Set rst = Nothing
    Exit Sub

    Err_Command51_Click:
    MsgBox Err.Description
    Resume Exit_Command51_Click
    End Sub

    Note: I recommend giving controls on forms and reports meaningful names. Using names such as Command51 don't give any clue to the purpose of the command button. If you name it cmdFindDate or something like that, it is immediately clear what it does.

Posting Permissions

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