A Search Form with an If/Then Statement

JeRz653

New member
Local time
Today, 16:19
Joined
Mar 17, 2016
Messages
5
Hi All,

I apologize if this is not in the correct area but, I am unsure where this falls.

I have a form that starts out with one field, [FamilyID] and a search button. The intent is to search the database to see if that exists. If it does, then the user would be sent to the IssueEntry form to continue. If there is no record found, the user is taken to the AddFamily form.

Can anyone provide any guidance on how to achieve this?

Thank you!
 
Few questions: What type of data is FamilyID--it sounds like a number. Will user's know family numbers? If not and FamilyID is text, it sounds like you've chosen a poor ID. How many FamilyID values are there? If not that many, you should use a drop down instead of a text input and have users select the FamilyId from a list of valid ones instead of having them type them.

With that said, here's the broad strokes of what you want to do. I am assuming that FamilyId is the unique primary key of the table Family.

1. Add code to the OnClick event of the Search button.

2. That code will do a DCount (http://www.techonthenet.com/access/functions/domain/dcount.php) into your Family table and assign that value to a variable.

3. If that variable is 1, you do a DoCmd.OpenForm (https://msdn.microsoft.com/en-us/library/office/ff820845.aspx), opening the AddFamily form, passing it the FamilyID.

4. If that variable is not 1, you will do a DoCmd.OpenForm, opening the AddFamily form, passing it no information.

Give it a shot and post back specific questions you have.
 

Users who are viewing this thread

Back
Top Bottom