This post isn’t anything ground breaking or new but I remember the first time I tried to do this! Also every time I do it I always forget something
The requirement here is simple
Create a form that allows the user to enter some search criteria and have it search across specific, multiple columns
There may be a Customers list (which may not be too different to the Northwind database in Access 2007…wink, wink). This list holds lots of details including the customers name, address, phone number, post code, current balance, account number
When the customer calls you need to be able to call up their details quickly. To identify the customer you may ask for an account number, a post code, etc (even just a part of that information – first three digits of their post code for example) which is why this needs to work across multiple columns
You may be thinking “why don’t you just use the built-in search functionality?”
The built-in search functionality in SharePoint is still a great tool (and we’ll leave Search Server Express out of this for now!) but the main problem in this scenario it doesn’t work as we as I only want to search on specific fields
So to get this running first create a Web Part Page
Click “site actions”, “create”, “Web part page”
Enter a name for your page (We’ll use “customer search” here), select a layout template and select a document library to store the page in and click OK
Once you’ve done that you will be taken to the new page. It will be in edit mode ready for you to add some web parts!
Click “Add a web part”, select a “Form Web Part” and click OK
If you just wanted to search on one specific column you could add your list to the page, setup a web part connection and never have to touch SharePoint designer!
But why do things the easy way? 🙂
Open SharePoint Designer, then open your site and then open your Customer Search Web Part page (if you want to take a copy of that file, now is the time to do it before we mess with it!)
Click on the “Data View” menu and select “Insert Data View”. The data source task library task pane will open and ask you to choose a list.
Select your customer list and click “Show Data”
Hold down your CTRL button and pick some fields. I’m going to pick
First Name, Last Name, Company, Business Phone and Zip/Postal Code
Then click the “Insert Selected Fields as” menu and select the “Multiple Item View” option
The data view will then be inserted into your page.
Click the > button for the data view so you get the common tasks menu and select the “parameters” option. In the Data View Parameters dialog select “New Parameter”
Give your parameter a name (i’m using “SearchValue”) and change the parameter source to CONTROL and the CONTROL ID to the ID of your FORM WEB PART (If your following these instructions or haven’t changed the ID it’s more than likely T1) and click OK
Then, from the command task menu of the data view select “Web Part Connections”. In the first page of the wizard select the “Get Parameters From” option.
On the second page leave the default “connect to a web part on this page” option selected
On the third page set the target web part to be form web part and the target action as “Provide form values to”
On the fourth page look for your }
There may be a better way of doing this but it works for me. If you know of a better way please let me know!
You can also change DispForm to EditForm if you want to be able to go straight to editing the record
Keep an eye on the “Text to display field” as this tries to mirror the address field and this isn’t always what you want
Save the page again and marvel at your finished project!
The northwind demo data is a bit pants for testing this to be honest but it does the job
As you know the latest version of SharePoint (v3 / 2007) is going to be a part of SBS 2008 and there is a lot of potential for helping your clients make the most of the product so get learning!
Latest posts by Andy Parkes (see all)
- Failed to Convert the Virtual Disk - June 14, 2020
- Tech Support Scam – McAfee Variant - May 5, 2020
- OnePlus 6T No Internet Connection After Switching From Wireless - February 3, 2020