View Full Version : Need help with search code


Mike Hughes
10-28-2007, 04:57 AM
I have a small DB which contains 2 tables and two forms. The tables are CaseStatus and Table1. The forms are frmCourtOrders and frmSearch. The user enters new cases on the frmCourtOrders. I want to give the user the ability to search that form on the field Docket Number, So I put a search button on the form which opens the frmSearch which would allow them to enter the docket number they are searching for.

Here is where the problem is. I don’t know how to write code. What I want the frmSearch form to do is to allow the worker to enter the Docket Number they are looking for and when they hit enter after adding the Docket Number the system would search the CaseStatus table for that docket number, close the frmSearch and open the frmCourtOrders displaying the correct record for that docket number. Can someone show me how to do this by putting in the code for me? I have attached the DB. I’m working in Access 2003

ajetrumpet
10-28-2007, 09:01 AM
Mike,

You will simply use two lines here, one for opening the first form on a WHERE condition, and the second to close the search form. This is pretty easy to get a handle on.

Look up the DoCmd.OpenForm method and the DoCmd.Close method in the help menu. It will tell you what to do. If you have a difficult time reading the syntax for the commands, post back here.

Zigzag
10-28-2007, 09:40 AM
Hi Mike,

I have an alternative for you that is so easy,

Open FrmCourtOrder in design view
Drag down the Detail bar about a inch
With the control wizard switched on,
Click the ComboBox control and add it to the space you created between Form Header and Detail.
If the Wizard is on, once you have put the combobox on you form the wizard will kick in.

The first queston has three options, Choose the 3rd option
"Find a record on my form blar blar blar"
Click Next
Select Dcoket Number
Click Next
Click Next
Click Finish
Now Left click on the new Combo box and select Change To from the 1st list then select Text Box off the 2nd list next.

When the form is now opened.
Type a docket number in the text box.
When press Enter the form will now find the docket number you entered.
All the VBA has now been created for you to examine.

Garry

Zigzag
10-28-2007, 09:44 AM
If you get stuck, here it is.

Garry