473,398 Members | 2,812 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,398 software developers and data experts.

multiple stLinkCriteria?

Hello all,

Iam a complete beginner, so please be gentle. Im trying to (if
possible) create a form to be used as a "search" facility of another
form.

All users list their favourite foods:
dave eggs chocolate
steve cheese chocolate
tony beef chocolate

And so in my search I have a combobox of eggs, chocolate, cheese, and
beef.
Should eggs be selected I would like only dave to be shown on the next
form. Though if chocolate is selected, then all three need o be
shown.

So far I've got:
stLinkCriteria = "[food1]=" & "'" & Me![chooser] & "'" And "[food2]="
& "'" & Me![chooser] & "'"
but this doesnt work, and is probably not the most elegant way of
doing this.

Any ideas?

Many thanks
Ed
Nov 12 '05 #1
1 5413
universal wrote:
Hello all,

Iam a complete beginner, so please be gentle.
We are programmers here, not wolves trying to deflower a virgin.
Im trying to (if
possible) create a form to be used as a "search" facility of another
form.

All users list their favourite foods:
dave eggs chocolate
steve cheese chocolate
tony beef chocolate

And so in my search I have a combobox of eggs, chocolate, cheese, and
beef.
Should eggs be selected I would like only dave to be shown on the next
form. Though if chocolate is selected, then all three need o be
shown.

So far I've got:
stLinkCriteria = "[food1]=" & " ' " & Me![chooser] & "'" And "[food2]="
& "'" & Me![chooser] & "'"
but this doesnt work, and is probably not the most elegant way of
doing this.

Any ideas?

Many thanks
Ed


It appears you have 2 fields; Food1 and Food2. In your criteria you are
using an AND. I really believe you mean OR. What you are asking is "Give
me all records in this table where the favorite food in field1 is
chocolate and the favoirite food is chocolate in food2" Since I don't
see any people that are choco-holics and eat chocolate only, the result
should be zero records returned.

I suggest you go to google http://www.google.com or to the newsgroup
search engine at http://groups.google.com and enter the advanced search
area. Then do a search on truth tables. When you new to programming
truth tables can be confusing. I'm sure you'll find some computer pros
that have spent some debugging time trying to figure out what is wrong
with the code and then finding out their and/or logic is off.

Here's a common mistake. 1 and 2 or 3. Did you really want something
where the value is 1 and in the second value either a 2 or 3. It
certainly can't be a 1 and 2 and a 3. It can't be both 1 and 2 or a 3.
To correct it may be 1 and (2 or 3)

Now to correct your problem.
Dim strWhere as string
If not isnull(MeChooser) then _
strWhere = "[Food1] = '" & Me.Chooser & :"' Or [Food2] = '" &
Me.Chooser & "'"
(I put the single quotes inside. Less &'s)

I'm not sure why you need 2 columns for the food. I'm sure you have a
reason for that. If you ever want to select multiple foods you would want
to consider the word In. Ex:
strWhere = "[Food1] In ("Eggs","Grits","Waffles")

Nov 12 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: April | last post by:
I am working on a database to be used for auditing medical groups. TABLE:DETAILS contains these fields: (autonumber) 50 group fields through each a combo box that pulls from the same...
0
by: cwm137 | last post by:
I have a form named "Customer Search" with a subform called "Cust Search Subform" that contains summary data about every order a customer has made. I would like to be able to select a single order...
4
by: Beejer | last post by:
Greeting, I'm trying to launch an OpenForm function with a double criteria. I can't seem to make them work together, the two criteria work seperatly so I assume my code to synchronise both...
14
by: leeg | last post by:
Hi, Really appreciate some help with the following: ps I am very poor at VBA! I have a form and when clicking a cmdbutton want to open the same form but with a different underlying query. I...
1
by: jpr | last post by:
Hello, I am reposting a question submitted some time ago to which I did not get much help, hoping for additional advice. My database has two tables. Table1 and Table2. Table2 is a copy of...
1
by: wavbuser | last post by:
Hi, I am a very new user to access databases, i'm trying to create a command button that opens a new form to a spefic record with multiple matching keys, if there is no match then start a new...
2
by: mark mestrom | last post by:
hi, i have this problem with OpenForm and the stLinkCriteria. I have the following code: Private Sub Knop22_Click() On Error GoTo Err_Knop22_Click Dim stDocName As String Dim...
4
by: crazyhouse | last post by:
This is the line of code i am trying to use. It doesnt work. I want the form to open only records that match the inspectjn, and accqty isnull. inspectjn is text accqty is a number ...
14
by: Desitech | last post by:
I am trying to get one value to return more than one linked field. The single link works. This is the code that works. Private Sub Command27_Click() If IsNull(CboGolfer) Then MsgBox "MUST...
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
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.