Consulting

Results 1 to 2 of 2

Thread: VBA Right function

  1. #1
    VBAX Newbie
    Joined
    Nov 2007
    Posts
    1
    Location

    VBA Right function

    hi all

    can plz someone tell me why the following code doesn't give me the expected results. if i do the exact search for strSearchVin = strVinNum...it gives me the correct results but somehow doesn't work with RIGHT function. I wana look up my results from the text box (by exact number or last 5 matching numbers). Thanks

    Private Sub cmdSearch_Click()
    Dim strVinNum As String
    Dim strSearchVin As String

    'Check for Null value

    If IsNull(Me![txtVinSearch]) Or (Me![txtVinSearch]) = "" Then
    MsgBox "Please enter a value!", vbOKOnly, "Invalid Search"
    Me![txtVinSearch].SetFocus
    Exit Sub
    End If



    DoCmd.ShowAllRecords
    DoCmd.GoToControl ("EquipSerialNum")
    DoCmd.FindRecord Me!txtVinSearch

    EquipSerialNum.SetFocus
    strVinNum = EquipSerialNum.Text
    txtVinSearch.SetFocus
    strSearchVin = txtVinSearch.Text


    If strSearchVin = Right(strVinNum, 5) Then
    EquipSerialNum.SetFocus
    txtVinSearch = ""

    Else
    MsgBox "Match Not Found", _
    txtVinSearch.SetFocus
    End If
    End Sub

  2. #2
    VBAX Mentor asingh's Avatar
    Joined
    Jul 2005
    Posts
    307
    Location
    Hi,
    try

    If strSearchVin = val(Right(strVinNum, 5)) Then
    ....
    ....

    end if

Posting Permissions

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