Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VBA Question

Status
Not open for further replies.

InsaneProgrammer

Programmer
Jan 17, 2001
44
US
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 &quot;Cannot find that Contract#&quot;, vbOKOnly, &quot;Results of Contract# Search&quot;
DoCmd.GoToRecord , , acNewRec

End If
End If
End Sub
 
worked fine on my Pc. You may have a Corrupted form, and need to recreate it.

PaulF
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top