A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Using Forms
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Multiple-criteria search on form, to open form



 
 
Thread Tools Display Modes
  #1  
Old February 17th, 2010, 08:11 PM posted to microsoft.public.access.forms
Mac
external usenet poster
 
Posts: 330
Default Multiple-criteria search on form, to open form

I know that there are queries that can do this, but I want to try to get this
functionality on a form looking like this. After clicking 'Search', a table
should return the filtered information. Please let me know if this is
possible, and HOW to do it... preferably step by step? Thank you in advance.
If all fields are empty, should return ALL records in table, correct?

_______________________________
|Enter search criteria below |
| ___________ |
|Name | John | |
| |__________| |
| ___________ |
|Amount $ | $50 | |
| |__________| |
| ___________ |
|Date (pick)| | |
| -On | | |
| -Between |__________| |
| ______________ |
| |_S_e_a_r_c_h_| --button |
|______________________________|
  #2  
Old February 17th, 2010, 08:14 PM posted to microsoft.public.access.forms
Mac
external usenet poster
 
Posts: 330
Default Multiple-criteria search on form, to open form

Sorry, not to 'open form' to open 'filtered table' or 'query' ??

"Mac" wrote:

I know that there are queries that can do this, but I want to try to get this
functionality on a form looking like this. After clicking 'Search', a table
should return the filtered information. Please let me know if this is
possible, and HOW to do it... preferably step by step? Thank you in advance.
If all fields are empty, should return ALL records in table, correct?

_______________________________
|Enter search criteria below |
| ___________ |
|Name | John | |
| |__________| |
| ___________ |
|Amount $ | $50 | |
| |__________| |
| ___________ |
|Date (pick)| | |
| -On | | |
| -Between |__________| |
| ______________ |
| |_S_e_a_r_c_h_| --button |
|______________________________|

  #3  
Old February 22nd, 2010, 06:23 PM posted to microsoft.public.access.forms
Daryl S[_2_]
external usenet poster
 
Posts: 881
Default Multiple-criteria search on form, to open form

Mac -

They way to do this is to build your filter when the Search button is
clicked. Then open the form to show the recrods using the criteria. Here is
the shell of the code for your button_click event. You will need to change
all names to match your form, control, and fieldnames.

Dim strCriteria as String

strCriteria = ""

If len(Me.Name) 0 Then
strCriteria = "WHERE [fldName] = '" & Me.Name & "'"
End If

If nz(Me.Amount,0) 0 Then
If strCriteria = "" Then
strCriteria = "WHERE [fldAmount] = " & Me.Amount
Else
strCriteria = strCriteria & " AND [fldAmount] = " & Me.Amount
End If
End If

If (nz(Me.Date1,0) 0) AND (Me.optDate = 1) Then 'On date chosen
If strCriteria = "" Then
strCriteria = "WHERE [fldDate] = #" & Me.Date1 & "#"
Else
strCriteria = strCriteria & " AND [fldDate] = #" & Me.Date1 & "#"
End If
End If

If (nz(Me.Date1,0) 0) AND (Me.optDate = 2) Then 'Between Dates chosen
If strCriteria = "" Then
strCriteria = "[fldDate] = #" & Me.Date1 & "#"
Else
strCriteria = strCriteria & " AND [fldDate] = #" & Me.Date1 & "#"
End If

If (nz(Me.Date2,0) 0) Then
strCriteria = strCriteria & " AND [fldDate] = #" & Me.Date2 & "#"
End If
End If

' Now open the form to show the records, and pass in this criteria:

DoCmd.OpenForm "FormName", acNormal, , strCriteria
--
Daryl S


"Mac" wrote:

Sorry, not to 'open form' to open 'filtered table' or 'query' ??

"Mac" wrote:

I know that there are queries that can do this, but I want to try to get this
functionality on a form looking like this. After clicking 'Search', a table
should return the filtered information. Please let me know if this is
possible, and HOW to do it... preferably step by step? Thank you in advance.
If all fields are empty, should return ALL records in table, correct?

_______________________________
|Enter search criteria below |
| ___________ |
|Name | John | |
| |__________| |
| ___________ |
|Amount $ | $50 | |
| |__________| |
| ___________ |
|Date (pick)| | |
| -On | | |
| -Between |__________| |
| ______________ |
| |_S_e_a_r_c_h_| --button |
|______________________________|

 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 09:35 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.