UtterAccess.com
X   Site Message
(Message will auto close in 2 seconds)

Welcome Guest ( Log In | Register )

 
Reply to this topicStart new topic
> Ignore Blank Entry On Forms Which Are Sent To A Query    
 
   
stolie
post Feb 23 2012, 06:59 PM
Post #1

New Member
Posts: 17



HI

I have a form set up in which the user inputs various searh terms which are linked to queries and the results are presented on a report.

As there aer 7 search input areas, and sometimes these are blank, the search can take up to 30sec- 1min to return (yes its is a large database!)

Upon hitting the "search all " comannd , im presuming that it is doing a search regardless of the blank input.


I would like to speed this up and i thought that if i could get the form to not run the query if there is no entry that this would help?

Soooo, how do i get it to ignore a Null entry?

thanks in advance!
Go to the top of the page
 
+
Jeff B.
post Feb 23 2012, 07:23 PM
Post #2

UtterAccess VIP
Posts: 8,188
From: Pacific NorthWet



Please post the code 'behind' that <search all> command button. We can't tell what it's supposed to do if you don't tell us the code.

One approach to doing what you describe would be to have code behind that button that dynamically builds a SQL-statement, leaving out WHERE clauses for the controls that have no entries.

NOTE: if someone types something into a control, then deletes it and moves on, I'm under the impression that Access no longer treats that as Null. Better check it out!
Go to the top of the page
 
+
stolie
post Feb 23 2012, 07:35 PM
Post #3

New Member
Posts: 17



Thanks for you reply.

The 'search all' is opening another report full of subreports , linked to queries!

An example of a query criteria is

Like "*" & [Forms]![MasterCOMBINEDSearchForm]![txtRego] & "*"


Where txtRego is obtained from the search form. Im figuring i need something like where txtRego is null, but coding is not my strength!

Cheers
Go to the top of the page
 
+
John Vinson
post Feb 23 2012, 08:16 PM
Post #4

UtterAccess VIP
Posts: 2,594
From: Parma, Idaho, US



The quick and dirty is to change all instances of

Like "*" & [Forms]![MasterCOMBINEDSearchForm]![txtRego] & "*"

to

=[Forms]![MasterCOMBINEDSearchForm]![txtRego] OR ([Forms]![MasterCOMBINEDSearchForm]![txtRego] & "" = "")

If the table fields are properly indexed this query will use those indexes, and be MUCH faster.

A better solution is to use VBA code to loop through the MasterCOMBINEDSearchForm's controls and build a SQL string for all the non-blank entries. Post back if you need to do it this way.
Go to the top of the page
 
+
stolie
post Feb 23 2012, 11:38 PM
Post #5

New Member
Posts: 17



Excellent thankyou VERY MUCH

Wasnt working at first for some reason, then it suddenly did!

Works a lot faster now, even when converting it back to a Contains type search

I have all my fields indexed that im using for searching

cheers
Go to the top of the page
 
+
John Vinson
post Feb 24 2012, 12:15 AM
Post #6

UtterAccess VIP
Posts: 2,594
From: Parma, Idaho, US



Note that your LIKE "*" & <fitb> & "*" search will NOT be able to use any indexing on the field. Indexing works on exact matches, or on "first character" matches like

LIKE field = <parameter> & "*"

Having a leading wildcard makes indexes useless.
Go to the top of the page
 
+

Thank you for your support! Reply to this topicStart new topic

Jump To Forum:
 



RSS Go to Top  ·  Lo-Fi Version Time is now: 18th June 2013 - 12:13 AM