Results 1 to 2 of 2

Thread: Database search on Date or Numeric fields

  1. #1

    Thread Starter
    Member JPRoy392's Avatar
    Join Date
    Aug 2000
    Posts
    50
    Please Help -

    I have searching a database (Access) for strings down cold. The problem that I am having is trying to do a search for fields in a database that are either characterized by date or number. (If I want to find an order number or the date an order was placed). Here is the code that I have for the string search:

    code:
    Option Explicit
    Dim sFindString As String

    Private Sub cmdFind_Click()
    If optName.Value = True Then
    If cmdFind.Caption = "F&ind" Then
    sFindString = InputBox("Enter the Name of the Vendor")

    If sFindString = "" Then
    Exit Sub
    End If

    Adodc1.Recordset.Find "COMPANY Like '" & _
    sFindString & "*'", 0, adSearchForward,
    adBookmarkFirst

    cmdFind.Caption = "F&ind Next"
    Else

    Adodc1.Recordset.Find "COMPANY Like '" & _
    sFindString & "*'", 1, adSearchForward,
    adBookmarkCurrent
    End If

    If Adodc1.Recordset.EOF Then
    MsgBox "Match Not Found", _
    vbInformation, "Vendor Search"
    Adodc1.Recordset.MoveFirst
    cmdFind.Caption = "F&ind"
    End If

    Thank you for any help
    Jim

    "...head is all empty and I don't care..."

  2. #2
    Frenzied Member
    Join Date
    Aug 1999
    Location
    Santa Clara, Ca , 95058
    Posts
    1,105
    For numeric data, don't wrap the variable (use 25 instead of "25").

    For dates, (and Access) use the "#" to wrap the date.

Posting Permissions

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



Click Here to Expand Forum to Full Width