Solved

Filters

Posted on 1999-01-18
8
308 Views
Last Modified: 2012-05-04
I have a form in VB5 and I want to filter on 4 of the fields on the form could be all the 4 or only one of them. These fields read from a recordset so the final result when I browse through, iwill only see these filtered records.
thank you
0
Comment
Question by:abidr
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 4
8 Comments
 

Author Comment

by:abidr
ID: 1469227
Edited text of question
0
 
LVL 12

Accepted Solution

by:
mark2150 earned 40 total points
ID: 1469228
Put a button on the form that triggers the lookup. When it does, simply build your query to match.

In this example a build a query based on the assumption that two fields are filled in. Then I test to see if one or the other field has been left blank and adjust my query accordingly. Finally I run the query and check to make sure that at least one record has been returned. My table is called RESULTS and there are at least two fields, CLIENT and DEBTOR. My form has a pair of text boxes CLIENT and DEBTOR. My database, DB, is already standing open.

SortKey = "select * from results where client like '" & client.Text & "*' or debtor=" & debtor.Text
If Len(debtor.Text) < 1 Then SortKey = "select * from results where client like '" & client.Text & "*'"
If Len(client.Text) < 1 Then SortKey = "select * from results where debtor=" & debtor.Text
'
Set rs = db.OpenRecordset(SortKey)
If rs.BOF And rs.EOF Then GoTo isempty

0
 

Author Comment

by:abidr
ID: 1469229
thanks,
As my knowledge is ltd, I can understand that the sql makes the filter, but how can I browse thru the filtered records of the results table or the query.
0
PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

 
LVL 12

Expert Comment

by:mark2150
ID: 1469230
You can load them in a control or show them one at a time with an entry screen type of page. Simply copy the contents of each field into a TextBox's .Text property. Put a couple of buttons on the page, [Next] and [Prev]. Have them perform a .MoveNext and .MovePrev in the filtered data set and then call the sub to load the current record onto the screen. Be sure to check .EOF and .BOF prior to call to prevent "No Current Record" errors.

PRIVATE SUB Btn_Next_Click()
rs.MoveNext
if rs.EOF then
  call clearpage
  Btn_Next.Enabled = False
else
  call showrecord
endif
END SUB

PRIVATE SUB Btn_Prev_Click()
rs.MovePrev
if rs.EOF then
  call clearpage
  Btn_Prev.Enabled = False
else
  call showrecord
endif
END SUB

PRIVATE SUB ShowRecord()
for ndx = 1 to Text1.Ubound
  Text1(ndx).Text = ""
next ndx
'
text1(1).Text = rs![field 1]
.

END SUB

M

0
 

Author Comment

by:abidr
ID: 1469231
Thanks,
I managed to filter & view records, but if I want to make a new search, I need to cancel the first filter and how can I cancel the first filter before performing another from the same table.
0
 
LVL 12

Expert Comment

by:mark2150
ID: 1469232
All you do is do a RS.CLOSE to shut down the first query and then re-run the OPENRECORDSET with the new params.

M

0
 

Author Comment

by:abidr
ID: 1469233
thanks  a lot, I have more of these.
0
 
LVL 12

Expert Comment

by:mark2150
ID: 1469234
No problem. Write me direct at:

mark_lambert@ntsc.navy.mil

M

0

Featured Post

[Live Webinar] The Cloud Skills Gap

As Cloud technologies come of age, business leaders grapple with the impact it has on their team's skills and the gap associated with the use of a cloud platform.

Join experts from 451 Research and Concerto Cloud Services on July 27th where we will examine fact and fiction.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses
Course of the Month6 days, 19 hours left to enroll

623 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question