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 biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

no data

Status
Not open for further replies.

hdgirl

Technical User
Feb 2, 2002
131
GB
I have posted this problem in the forms section but am still unable to resolve it so i thought i would try it here,
I have an input box that asks for a works order number this then opens the relevant record for that number, but if a number is entered that doesn't exist then it opens a new record. So how can i get it to say "the number does not exist"

here is the code that i am using

Private Sub cmdOpenRec_Click()

Dim strWorksOrderNumber As String, strFilter As String
strWorksOrderNumber = InputBox("Please Enter W/O Number")


If strWorksOrderNumber = "" Then

GoTo Exit_This_Sub
End If

strFilter = "[WorksOrderNumber] = " & Trim(Str(strWorksOrderNumber))
DoCmd.OpenForm "frmAdmin", acNormal, , strFilter
Exit_This_Sub:
Exit Sub

End Sub

If i remove the goto statement and insert a messagebox when i enter no data the message box appears but not if i insert a works order number that doesn't exist

Any help would be appreciated
Thanks CJB
 
Well surly you would have to check whether the filter returns any values. if it does then go to the form, if not display the message and go to the addnew form. The other way of doing it would be if the form runs the filter and has no results it says it is adding a new record. ie do it in the form not the calling form (if that makes sense)

hth
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top