Search Querry (1 Viewer)

dadrew

Registered User.
Local time
Today, 01:59
Joined
Sep 15, 2003
Messages
186
I have created a search form made up of a number of different boxes. In my querry for the search I am using the following statement:

Like "*" & [Forms]![Search]![ExerciseName] & "*"

I a have a number of theses all saying similar things. At present I have to put something in each of the search boxes. Is there a way that I can leave a box blank and still search by other criteria. If I leave a box blank at present it returns no results.
 

KenHigg

Registered User
Local time
Yesterday, 20:59
Joined
Jun 9, 2004
Messages
13,327
Are you starting the query off a cmd button click?
 

dadrew

Registered User.
Local time
Today, 01:59
Joined
Sep 15, 2003
Messages
186
Yes I am! Does that make a difference?
 

KenHigg

Registered User
Local time
Yesterday, 20:59
Joined
Jun 9, 2004
Messages
13,327
Hum... Kinda.

I was just going to say that, in that case, I'd do a pc of code that checks all the flds and builds a custom sql string for the search...

Make sense?
 

dadrew

Registered User.
Local time
Today, 01:59
Joined
Sep 15, 2003
Messages
186
:rolleyes: Hmmmm! Not really, early learning centre for me I'm afraid!
 

KenHigg

Registered User
Local time
Yesterday, 20:59
Joined
Jun 9, 2004
Messages
13,327
Then in that case what about a pc of code that checks each text box. If the text box is empty, it places a wild card char in it...?
 

dadrew

Registered User.
Local time
Today, 01:59
Joined
Sep 15, 2003
Messages
186
:eek: Ok, how, please. Ive got so used to doing searches by using a querry Im a bit lost!
 

KenHigg

Registered User
Local time
Yesterday, 20:59
Joined
Jun 9, 2004
Messages
13,327
What exactly is the code that you have that runs the search?
 

dadrew

Registered User.
Local time
Today, 01:59
Joined
Sep 15, 2003
Messages
186
Private Sub Command11_Click()
On Error GoTo Err_Command11_Click

Dim stDocName As String
Dim stLinkCriteria As String

Me.Visible = False

stDocName = "Search"
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_Command11_Click:
Exit Sub

Err_Command11_Click:
MsgBox Err.Description
Resume Exit_Command11_Click

End Sub
 

KenHigg

Registered User
Local time
Yesterday, 20:59
Joined
Jun 9, 2004
Messages
13,327
That opens the search form, how do you get it to look for records after it's open?
 

dadrew

Registered User.
Local time
Today, 01:59
Joined
Sep 15, 2003
Messages
186
WHOOPS! Posted the wrong code!

Private Sub Command14_Click()
On Error GoTo Err_Command14_Click

Dim stDocName As String

DoCmd.RunMacro "Search"
stDocName = "Search1"
DoCmd.OpenReport stDocName, acPreview

Exit_Command14_Click:
Exit Sub

Err_Command14_Click:
MsgBox Err.Description
Resume Exit_Command14_Click

End Sub
 

KenHigg

Registered User
Local time
Yesterday, 20:59
Joined
Jun 9, 2004
Messages
13,327
I'm affraid you've lost me... Maybe someone else will jump in :)
 

Users who are viewing this thread

Top Bottom