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

    Home » Forums » AskWoody support » Productivity software by function » MS Access and database help » change a code written for a string value? (Access 2000)

    Author
    Topic
    #363914

    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

    Viewing 1 reply thread
    Author
    Replies
    • #556933

      Sory wrong thread

    • #556936

      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

    Viewing 1 reply thread
    Reply To: change a code written for a string value? (Access 2000)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: