InsaneProgrammer
Programmer
I wrote a simple program to let the user search for a specifc record by Contract#. I have used this same piece of code before but for some reason this time the final if statement will never execute. If there is no record matching the users input the msgbox saying "Cannot find that contract#" will not execute. Does anyone have any ideas? THANKS!
Private Sub SearchContract__Click()
Dim strInput As String
Dim strMsg As String
strMsg = "Enter the Contract# you are looking for."
strInput = InputBox(Prompt:=strMsg, Title:="Search By contract#", XPos:=6000, YPos:=3000)
If (strInput = ""
Then
Beep
MsgBox "You did not enter a value"
End
Else
DoCmd.ShowAllRecords
DoCmd.GoToControl "ContractNumber"
DoCmd.FindRecord strInput
If ([ContractNumber] <> strInput) Then
Beep
MsgBox "Cannot find that Contract#", vbOKOnly, "Results of Contract# Search"
DoCmd.GoToRecord , , acNewRec
End If
End If
End Sub
Private Sub SearchContract__Click()
Dim strInput As String
Dim strMsg As String
strMsg = "Enter the Contract# you are looking for."
strInput = InputBox(Prompt:=strMsg, Title:="Search By contract#", XPos:=6000, YPos:=3000)
If (strInput = ""
Beep
MsgBox "You did not enter a value"
End
Else
DoCmd.ShowAllRecords
DoCmd.GoToControl "ContractNumber"
DoCmd.FindRecord strInput
If ([ContractNumber] <> strInput) Then
Beep
MsgBox "Cannot find that Contract#", vbOKOnly, "Results of Contract# Search"
DoCmd.GoToRecord , , acNewRec
End If
End If
End Sub