Results 1 to 8 of 8

Thread: Look Up problem

  1. #1
    Join Date
    May 2004
    Posts
    86

    Unanswered: Look Up problem

    i have a form with two search boxes. One is ID and the other is OFFSET, with one search button. I wnat the user to be able to search by ID and Offset. i cant get the code below to work with the offset, it only searches by ID

    much help needed thanks


    Dim strStudentRef As String
    Dim strSearch As String

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

    DoCmd.ShowAllRecords
    DoCmd.GoToControl ("CFR_EHPID")
    DoCmd.FindRecord Me!Text5
    Text5.SetFocus

    strSearch = Text5.text
    CFR_EHPID.SetFocus
    strStudentRef = CFR_EHPID.text

    If strStudentRef = strSearch Then
    MsgBox "History Found For EHP ID#: " & strSearch & ""
    CFR_EHPID.SetFocus



    ElseIf strStudentRef <> strSearch Then
    DoCmd.ShowAllRecords
    DoCmd.GoToControl ("CFR_PATOFFSET")
    DoCmd.FindRecord Me!Text169
    Text169.SetFocus

    strSearch = Text169.text
    CFR_EHPID.SetFocus
    strStudentRef = CFR_PATOFFSET.text

    If strStudentRef = strSearch Then
    MsgBox "Matching Record Found!", vbOKOnly + vbExclamation, "Message"
    Text169.SetFocus
    Text169 = ""

    Else
    MsgBox "No Matching Record Found. Please Try Again!", vbOKOnly + vbInformation, "Message!"
    Text5.SetFocus
    Text5 = ""

    End If
    End If
    End Sub

  2. #2
    Join Date
    Apr 2002
    Location
    Portugal
    Posts
    146
    [QUOTE=petenyce105]i have a form with two search boxes. One is ID and the other is OFFSET, with one search button. I wnat the user to be able to search by ID and Offset. i cant get the code below to work with the offset, it only searches by ID

    much help needed thanks


    Dim strStudentRef As String
    Dim strSearch As String

    If IsNull(Me![Text5]) Or (Me![Text5]) = "" Then
    MsgBox "Please enter a EHP ID", vbOKOnly, "Invalid Search Criterion!"

    You have the same control [Text5].
    Why do you need the Logic OR?

  3. #3
    Join Date
    May 2004
    Posts
    86

    Well

    I have two text boxes on my form

    text 5 and text169 i use these for the user to place a value in before i hit search.

    the code i posted are for message boxes if no vaule is found or a vaule is found. Im trying to let the user enter a ID and a offset and search on those two feilds.......... I dont understand your last post..... and what you wrote?

  4. #4
    Join Date
    Apr 2002
    Location
    Portugal
    Posts
    146
    I'm saying that you are comparing the same control:

    if isnull(Text5 or Text5)

    and you are repeating what the function isnull does. You are putting the code:

    If IsNull(Me![Text5] or Me![Text5])=""

    What i don't understand is:

    Why ----> ="", if you are using isnull

    And

    Why-----> The same control TEXT5

  5. #5
    Join Date
    Dec 2002
    Location
    Préverenges, Switzerland
    Posts
    3,740
    (X or X) = X
    and for the fun of it: (Y and Y) = Y
    ...so this is only a waste of clock cycles. the problem lies elsewhere.

    if isnull(anything) = True then 'possible, valid, but a waste of space
    if isnull(anything) = False then 'possible, valid, but a waste of space

    if isnull(anything) = <any value other than True/False> 'will never happen

    specifically:
    if isnull(anything) = "" then 'will never happen

    instead consider:
    if nz(anything, "") = "" then 'occurs when Null or empty string



    your code does not talk of text169 or a user-input OFFSET!



    izy
    currently using SS 2008R2

  6. #6
    Join Date
    May 2004
    Posts
    86

    Ok thats The Message Box

    The is null part im not worried about thats for my message boxes. im more concerend about how to get both text boxes to search.. Right now the way my code is at the top it only searches by EHPID i want it to search by text5(EHPID) and text169(PATOFFSET)


    ANy help?

  7. #7
    Join Date
    Dec 2002
    Location
    Préverenges, Switzerland
    Posts
    3,740
    why don't you post what you have tried?
    your originally posted example doesn't even consider text169

    izy
    currently using SS 2008R2

  8. #8
    Join Date
    Apr 2002
    Location
    Portugal
    Posts
    146
    I agree with izyrider!

    We are not referring to the messagebox, but to the controls and the logic statments of your code!

Posting Permissions

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