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

Trouble with AND

I need help getting this syntax to work.
I want to open a form to a specific record based on dual criteria.
Both fields are text fields as is the input.
I get an error message "type mismatch"

stLinkCriteria = "[PartNumber]=" & "'" & Me![txtPartNumber] & "'" AND
"[ MacPacNumber]=" & "'" & Me![ txtMacPacExisting] & "'"
HELP,
Rick

Nov 13 '05 #1
11 1741

"2D Rick" <rb*******@compuserve.com> wrote in message
news:11*********************@l41g2000cwc.googlegro ups.com...
I need help getting this syntax to work.
I want to open a form to a specific record based on dual criteria.
Both fields are text fields as is the input.
I get an error message "type mismatch"

stLinkCriteria = "[PartNumber]=" & "'" & Me![txtPartNumber] & "'" AND
"[ MacPacNumber]=" & "'" & Me![ txtMacPacExisting] & "'"
HELP,
Rick


What are the data types in the tables?
Nov 13 '05 #2
delimiters
text: single quote, 'some text'
dates: #10/12/04#
numbers: nothing

Nov 13 '05 #3
You're using single quotes as delimiters. Does any of the data have an
apostrophe in it? What are the data types of the two fields in the
underlying table?

This part is probably the problem:
& "'" AND "[ MacPacNumber]="

Should be

& "' AND [MacPacNumber]="

The AND needs to be inside the quotes. It is part of the text being passed
to strLinkCriteria. The &'s are the "ands" for the concatenation.
Just to nit-pick a little.

]=" & "'" &
You don't need the extra set of quotes and & (but it shouldn't hurt
anything), this could be just
]='" &

"[ MacPacNumber]=", ![ txtMacPacExisting]
There is a space in front of the M and the t.

--
Wayne Morgan
MS Access MVP
"2D Rick" <rb*******@compuserve.com> wrote in message
news:11*********************@l41g2000cwc.googlegro ups.com...
I need help getting this syntax to work.
I want to open a form to a specific record based on dual criteria.
Both fields are text fields as is the input.
I get an error message "type mismatch"

stLinkCriteria = "[PartNumber]=" & "'" & Me![txtPartNumber] & "'" AND
"[ MacPacNumber]=" & "'" & Me![ txtMacPacExisting] & "'"

Nov 13 '05 #4
You're using single quotes as delimiters. Does any of the data have an
apostrophe in it? What are the data types of the two fields in the
underlying table?

This part is probably the problem:
& "'" AND "[ MacPacNumber]="

Should be

& "' AND [MacPacNumber]="

The AND needs to be inside the quotes. It is part of the text being passed
to strLinkCriteria. The &'s are the "ands" for the concatenation.
Just to nit-pick a little.

]=" & "'" &
You don't need the extra set of quotes and & (but it shouldn't hurt
anything), this could be just
]='" &

"[ MacPacNumber]=", ![ txtMacPacExisting]
There is a space in front of the M and the t.

--
Wayne Morgan
MS Access MVP
"2D Rick" <rb*******@compuserve.com> wrote in message
news:11*********************@l41g2000cwc.googlegro ups.com...
I need help getting this syntax to work.
I want to open a form to a specific record based on dual criteria.
Both fields are text fields as is the input.
I get an error message "type mismatch"

stLinkCriteria = "[PartNumber]=" & "'" & Me![txtPartNumber] & "'" AND
"[ MacPacNumber]=" & "'" & Me![ txtMacPacExisting] & "'"

Nov 13 '05 #5
stLinkCriteria = "[PartNumber]= ' " & Me![txtPartNumber] & " ' " _
& " AND [ MacPacNumber]= ' " & Me![ txtMacPacExisting] & " ' "

or

stLinkCriteria = "[PartNumber]= ' " & Me![txtPartNumber] & " ' AND [
MacPacNumber]= ' " & Me![ txtMacPacExisting] & " ' "

HTH,
Debbie
"2D Rick" <rb*******@compuserve.com> wrote in message
news:11*********************@l41g2000cwc.googlegro ups.com...
|I need help getting this syntax to work.
| I want to open a form to a specific record based on dual criteria.
| Both fields are text fields as is the input.
| I get an error message "type mismatch"
|
|
|
| stLinkCriteria = "[PartNumber]=" & "'" & Me![txtPartNumber] & "'" AND
| "[ MacPacNumber]=" & "'" & Me![ txtMacPacExisting] & "'"
|
|
| HELP,
| Rick

Nov 13 '05 #6
stLinkCriteria = "[PartNumber]= ' " & Me![txtPartNumber] & " ' " _
& " AND [ MacPacNumber]= ' " & Me![ txtMacPacExisting] & " ' "

or

stLinkCriteria = "[PartNumber]= ' " & Me![txtPartNumber] & " ' AND [
MacPacNumber]= ' " & Me![ txtMacPacExisting] & " ' "

HTH,
Debbie
"2D Rick" <rb*******@compuserve.com> wrote in message
news:11*********************@l41g2000cwc.googlegro ups.com...
|I need help getting this syntax to work.
| I want to open a form to a specific record based on dual criteria.
| Both fields are text fields as is the input.
| I get an error message "type mismatch"
|
|
|
| stLinkCriteria = "[PartNumber]=" & "'" & Me![txtPartNumber] & "'" AND
| "[ MacPacNumber]=" & "'" & Me![ txtMacPacExisting] & "'"
|
|
| HELP,
| Rick

Nov 13 '05 #7
pi********@hotmail.com wrote:
dates: #10/12/04#


Don't forget to mention dates in this format require to be in US format.

--
This sig left intentionally blank
Nov 13 '05 #8
I tried DebbieG's syntax and it didn't work.
The data will never contain an apostrophe and the table fields type are
both "text".
There should not be a space in front of the M and the t, My typo error.

This is my feeble attempt:
stLinkCriteria = "[PartNumber]=" & "'" & Me![txtPartNumber] & "'" And
"[MacPacNumber]=" & "'" & Me![txtMacPacExisting] & "'"
Wayne Morgan wrote:
You're using single quotes as delimiters. Does any of the data have an apostrophe in it? What are the data types of the two fields in the
underlying table?

This part is probably the problem:
& "'" AND "[ MacPacNumber]="

Should be

& "' AND [MacPacNumber]="

The AND needs to be inside the quotes. It is part of the text being passed to strLinkCriteria. The &'s are the "ands" for the concatenation.
Just to nit-pick a little.

]=" & "'" &
You don't need the extra set of quotes and & (but it shouldn't hurt
anything), this could be just
]='" &

"[ MacPacNumber]=", ![ txtMacPacExisting]
There is a space in front of the M and the t.

--
Wayne Morgan
MS Access MVP
"2D Rick" <rb*******@compuserve.com> wrote in message
news:11*********************@l41g2000cwc.googlegro ups.com...
I need help getting this syntax to work.
I want to open a form to a specific record based on dual criteria.
Both fields are text fields as is the input.
I get an error message "type mismatch"

stLinkCriteria = "[PartNumber]=" & "'" & Me![txtPartNumber] & "'" AND "[ MacPacNumber]=" & "'" & Me![ txtMacPacExisting] & "'"


Nov 13 '05 #9
> stLinkCriteria = "[PartNumber]=" & "'" & Me![txtPartNumber] & "'" And
"[MacPacNumber]=" & "'" & Me![txtMacPacExisting] & "'"
You still don't have the word AND inside the quotes. It should be part of
the string being passed to stLinkCriteria. Change the above to:

stLinkCriteria = "[PartNumber]=" & "'" & Me![txtPartNumber] & "' And
[MacPacNumber]=" & "'" & Me![txtMacPacExisting] & "'"

I have removed the double quote on each side of the word AND.

It could be (but doesn't need to be) further shortened to:

stLinkCriteria = "[PartNumber]='" & Me![txtPartNumber] & "' And
[MacPacNumber]='" & Me![txtMacPacExisting] & "'"
--
Wayne Morgan
MS Access MVP
"2D Rick" <rb*******@compuserve.com> wrote in message
news:11*********************@o13g2000cwo.googlegro ups.com...I tried DebbieG's syntax and it didn't work.
The data will never contain an apostrophe and the table fields type are
both "text".
There should not be a space in front of the M and the t, My typo error.

This is my feeble attempt:
stLinkCriteria = "[PartNumber]=" & "'" & Me![txtPartNumber] & "'" And
"[MacPacNumber]=" & "'" & Me![txtMacPacExisting] & "'"

Nov 13 '05 #10
Thanks Wayne, that did the trick.
Rick

Wayne Morgan wrote:
stLinkCriteria = "[PartNumber]=" & "'" & Me![txtPartNumber] & "'" And "[MacPacNumber]=" & "'" & Me![txtMacPacExisting] & "'"
You still don't have the word AND inside the quotes. It should be

part of the string being passed to stLinkCriteria. Change the above to:

stLinkCriteria = "[PartNumber]=" & "'" & Me![txtPartNumber] & "' And
[MacPacNumber]=" & "'" & Me![txtMacPacExisting] & "'"

I have removed the double quote on each side of the word AND.

It could be (but doesn't need to be) further shortened to:

stLinkCriteria = "[PartNumber]='" & Me![txtPartNumber] & "' And
[MacPacNumber]='" & Me![txtMacPacExisting] & "'"
--
Wayne Morgan
MS Access MVP
"2D Rick" <rb*******@compuserve.com> wrote in message
news:11*********************@o13g2000cwo.googlegro ups.com...
I tried DebbieG's syntax and it didn't work.
The data will never contain an apostrophe and the table fields type are both "text".
There should not be a space in front of the M and the t, My typo error.
This is my feeble attempt:
stLinkCriteria = "[PartNumber]=" & "'" & Me![txtPartNumber] & "'" And "[MacPacNumber]=" & "'" & Me![txtMacPacExisting] & "'"


Nov 13 '05 #11
I forgot to tell you to remove the spaces between the ' and ". I put the
spaces in so that you could see the difference between the ' and the ".

Sorry for the confusion,
Debbie
"2D Rick" <rb*******@compuserve.com> wrote in message
news:11*********************@o13g2000cwo.googlegro ups.com...
|I tried DebbieG's syntax and it didn't work.
| The data will never contain an apostrophe and the table fields type are
| both "text".
| There should not be a space in front of the M and the t, My typo error.
|
| This is my feeble attempt:
| stLinkCriteria = "[PartNumber]=" & "'" & Me![txtPartNumber] & "'" And
| "[MacPacNumber]=" & "'" & Me![txtMacPacExisting] & "'"
|
|
| Wayne Morgan wrote:
| > You're using single quotes as delimiters. Does any of the data have
| an
| > apostrophe in it? What are the data types of the two fields in the
| > underlying table?
| >
| > This part is probably the problem:
| > & "'" AND "[ MacPacNumber]="
| >
| > Should be
| >
| > & "' AND [MacPacNumber]="
| >
| > The AND needs to be inside the quotes. It is part of the text being
| passed
| > to strLinkCriteria. The &'s are the "ands" for the concatenation.
| >
| >
| > Just to nit-pick a little.
| >
| > ]=" & "'" &
| > You don't need the extra set of quotes and & (but it shouldn't hurt
| > anything), this could be just
| > ]='" &
| >
| > "[ MacPacNumber]=", ![ txtMacPacExisting]
| > There is a space in front of the M and the t.
| >
| > --
| > Wayne Morgan
| > MS Access MVP
| >
| >
| > "2D Rick" <rb*******@compuserve.com> wrote in message
| > news:11*********************@l41g2000cwc.googlegro ups.com...
| > >I need help getting this syntax to work.
| > > I want to open a form to a specific record based on dual criteria.
| > > Both fields are text fields as is the input.
| > > I get an error message "type mismatch"
| > >
| > > stLinkCriteria = "[PartNumber]=" & "'" & Me![txtPartNumber] & "'"
| AND
| > > "[ MacPacNumber]=" & "'" & Me![ txtMacPacExisting] & "'"
|

Nov 13 '05 #12

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

Similar topics

2
by: James | last post by:
Hi I am having some trouble getting a asp page to load. Im a noob to the asp side. I have followed knowledege base Article 301305. I am running 2000 adv, IIS 5.0 I have the following...
4
by: Jacek Dziedzic | last post by:
Hi! First of all, I hope my problem is not too loosely tied to the "standard C++" that is the topic of this group. I have some code that exhibits a strange behaviour: on one computer, where I...
0
by: Paul C | last post by:
Hello, everybody. I am having trouble running some of the VS.NET samples, specifically the CarSelector web app, which is very simple. The symptom is that the web controls (drop down listboxes and...
0
by: Alexandre Jaquet | last post by:
Hi does anybody know how to solve my trouble, when I try to create a MS Office project I always got trouble. I can't create office project when I try to create one vs.net restart ... :s
2
by: Jeff | last post by:
/* -------------------------------------------------------------------------- Hello, I was experimenting with class templates and specializing member functions and came across a simple problem...
1
by: Jim Bancroft | last post by:
Hi everyone, I'm running into a problem with my ASP.Net application. I've just created a new aspx page which uses some new components of mine that inherit from ServicedComponent and are...
6
by: Daniel Walzenbach | last post by:
Hi, I have a web application which sometimes throws an “out of memory” exception. To get an idea what happens I traced some values using performance monitor and got the following values (for...
3
by: Olivier BESSON | last post by:
Hello, I have a web service of my own on a server (vb.net). I must declare it with SoapRpcMethod to be used with JAVA. This is a simple exemple method of my vb source : ...
2
by: JLupear | last post by:
I am having trouble with my code again, I had prepared a question and the code to upload, however I am having trouble posting it, are there limits to the amount of lines you can post? I split it...
0
by: mrchatgroup | last post by:
news from http://www.mrchat.net/myblog/myblog/small-accidents-mean-big-trouble-for-supercollider.html Small Accidents Mean Big Trouble for Supercollider Image Scientists expect startup...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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: 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
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...
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 projectplanning, coding, testing,...

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.