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

This ID does not exist

Status
Not open for further replies.

ski2sun

Technical User
Sep 12, 2001
31
US
I have a table called Contacts. People search by entering an ID, and if it finds it goes to a form. How can I insert an error message or "ID does not exist" message prompt for those instances where the ID is not in the table. Can someone send sample code...thank you
 
Hey ski2sun:

I have done this very thing on similar occasions, when building my own password protection form, or even the ID search form like you are doing. This is how I've solved your problem.

In this particular code that I have pasted, it looks at the value of the control [S1], and it counts the SIC table for any matches. If it doesn't come up with 1 match it brings the message, "There is no such SIC CODE"

If DCount(&quot;[SIC Code]&quot;, &quot;SIC&quot;, &quot;[SIC Code]=[Forms]![MinSIC]![S1]&quot;) < 1 Then
MsgBox &quot;There is no such SIC CODE&quot;
DoCmd.RunCommand acCmdUndo
Else
End If

For better understanding it should be like this..

If DCount(&quot;[FieldNamewherematcheswouldbe]&quot;, &quot;Table in which the possible matches are&quot;, &quot;[fieldname]=[Forms]![form name where control is]![control name]&quot;) < 1 Then
MsgBox &quot;message you wish to display&quot;
DoCmd.RunCommand acCmdUndo
Else
The action you want to occur if they do find a match
End If


Let me know if this helps.
 
Bitech....
I guess I needed to clarify....I have a small db with what I intended to do...can I send to you to review. It might simplify my question...

it has a startup form which request ID #....it goes to another form if there is a matching ID (via a macro in the contacts form). If no ID exists, the form shows up blank.

What I would like to see is:

If practice Id in main form matches practice id in contacts form (and table), open up contacts form accordingly.

If practice ID in main form is not in contacts form (and table), I would like to give the user a message box option that says &quot;do you want to download practice ID?&quot; If yes, run a macro called 'Capture Group Data'. If no, it returns to main menu.

Could you help with this....this would be greatly appreciated.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top