473,395 Members | 1,411 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Using VBA filter on one or more fields

Hi,
I am trying to open a VB form based on stLinkCriteria, using 2 fields.
It is successful for me if both fields have information in them.
However I wish to be able to search on either field

Here is my code
Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "frmOpen"
stLinkCriteria = "[Code1]=" & "'" & Me![Code1] & "'" & " AND
[Code2]=" & "'" & Me![Code2] & "'"

DoCmd.OpenForm stDocName, , , stLinkCriteria

Can you tell me if it's possible to code it in a way to include AND/OR so that one filed can be blank

Thanks very much
NIall
Sep 11 '06 #1
3 4310
MMcCarthy
14,534 Expert Mod 8TB
stDocName = "frmOpen"
stLinkCriteria = "[Code1]=" & "'" & Me![Code1] & "'" & " OR
[Code2]=" & "'" & Me![Code2] & "'"

This will return all records where either field is true.

Hi,
I am trying to open a VB form based on stLinkCriteria, using 2 fields.
It is successful for me if both fields have information in them.
However I wish to be able to search on either field

Here is my code
Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "frmOpen"
stLinkCriteria = "[Code1]=" & "'" & Me![Code1] & "'" & " AND
[Code2]=" & "'" & Me![Code2] & "'"

DoCmd.OpenForm stDocName, , , stLinkCriteria

Can you tell me if it's possible to code it in a way to include AND/OR so that one filed can be blank

Thanks very much
NIall
Sep 11 '06 #2
Thanks for that.

What I am trying to do is return all records when eith one is true OR both fields are true. OR only works with one field.
Any suggestions?

niall
Sep 12 '06 #3
MMcCarthy
14,534 Expert Mod 8TB
Naill

I don't understand the question, if both are true then this satisfies that either are true. You should get a result either way.


Thanks for that.

What I am trying to do is return all records when eith one is true OR both fields are true. OR only works with one field.
Any suggestions?

niall
Sep 12 '06 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

14
by: David Lozzi | last post by:
OK, I know how to use to pull up all records that contains the keyword, but what about not containing the keyword? I've tried NOT LIKE but i get Arguments are of the wrong type, are out of...
3
by: arthur-e | last post by:
I can filter a query for a report on a field of a subform BUT now.... I'd like to be able to select more than one item in a multi-list box to select all the records. ALSO to use two fields (or...
0
by: CSDunn | last post by:
Hello, I have a problem with field filtering between an Access 2000 Project form (the application is called CELDT), and the report that shows the results of the filter. Both the form and the...
4
by: Stewart Allen | last post by:
I'm trying to filter a table that has 2 date fields, the first date will always have a value but the second will only occasionally has a value. Each date field also has a corresponding text field...
3
by: Afton | last post by:
I would like to make a form that filters a report by Supervisor and by starting and ending date. I have the supervisors in a combo box, and that works. However, I do not know how to code to let...
11
by: Grasshopper | last post by:
Hi, I am automating Access reports to PDF using PDF Writer 6.0. I've created a DTS package to run the reports and schedule a job to run this DTS package. If I PC Anywhere into the server on...
4
by: Kathy | last post by:
What is the standard technique for handling the fields in the following scenario on a continuous form? Multiple Divisions. Each Division has multiple Buildings. Each Building has a Supervisor. ...
21
KevinADC
by: KevinADC | last post by:
Note: You may skip to the end of the article if all you want is the perl code. Introduction Uploading files from a local computer to a remote web server has many useful purposes, the most...
1
by: Cara Murphy | last post by:
Hi There! Hoping you are able to help me with a filtering scenario: I have created a pop up form (Filter) to filter a report (Open Issues), which currently has a number of combo boxes which...
1
by: G04 | last post by:
Hi All, I have a continuous form with all records. For each field there is a combo in the form header and the form also contains a Toggle button "Apply Filter". When clicked, it changes to...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.