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

    change a code written for a string value? (Access 2000)

    I have copied a very useful code for me, but i cannot use it, since i cannot handle
    the CustomerID number in the table Customers. The table in the original example has a Text value for its CustomerID value.
    The code finds a customer by writing the leters on a control called FindIt, and then in the AfterUpdate event i find all the information

    about that customer.The code works fine in case that the CustomerId is a text field.
    But the CustomerId in my table is an Autonumber field. And i receive the error type mismatch.When i convert my
    CustomerId to be Text, then it works again fince, so obviously here is the mistake. But i need my CustomerId to be an Autonumber. But

    how can i imporve the code so that i works with a table where the Customerid is not a text but an Autonumber?
    Here is the whole original code i have copied:



    Private Sub Findit_AfterUpdate()
    'Use the bookmark to move to a the selected customer
    'From "Microsoft Access 2000 Development Unleashed" (SAMS)
    'By: Forte, Howe, Ralston
    Dim rsclone As DAO.Recordset
    Dim recordID As Variant
    Dim IDValue As String
    Set rsclone = Me.RecordsetClone
    IDValue = Me![Findit]
    recordID = "CustomerID = '" & IDValue & "'"
    rsclone.FindFirst recordID
    bm = rsclone.Bookmark
    Me.Bookmark = bm
    End Sub

    I have tried to replace DimIDValue as String with Dim IDValue As Integer
    but again no success.

    Will be grateful for any help

  2. #2
    Gold Lounger
    Join Date
    Feb 2001
    Location
    Sint Niklaas, Belgium
    Posts
    2,778
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: change a code written for a string value? (Access 2000)

    Sory wrong thread
    Francois

  3. #3
    Gold Lounger
    Join Date
    Feb 2001
    Location
    Sint Niklaas, Belgium
    Posts
    2,778
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: change a code written for a string value? (Access 2000)

    Aral,

    Sory for the previous message, I was in a wrong thread.

    Your have to adapt the code to

    Dim IDValue as Long

    and change the criteria line to

    recordID = "CustomerID = "& IDValue

    to find for a number.
    Numbers may not be quoted in find criterias, otherwise they are treated as text
    Francois

Posting Permissions

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