Totally new to MS Access but kind of finding my way around I tried something
simple and it is becomming a pain.
I created a simple table as follows
Field 1 = "This is Fred" , "This is George"
Field 2 = "Fred" , "Adam"
Field 3 = 1 , 2
Field 4 = 01/04/05 , 05/05/05
The comma separates the 2 rows of data I entered.
I then created a Query (all using the Design mode not quite comfortable with
SQL yet)
A query was simple enough , just dragged all the fields 1 to 4 down, then I
thought I try to create an extra field using the "Build" option on the
Criteria and wrote the syntax via "Built in Functions", the field name
became "Expr1: [TestMe]" the syntax I built as follows
IIf([TestTable]![Field 1] Like "*" & [TestTable]![Field 2] & "*",1,0)
What I was attempting to do was simply say that if Field 1 is LIKE value in
Field 2 then 1 else 0, what the damn thing is doing is giving me an "Enter
Parameter Value" dialog box, which is what I do not want , I expected to get
a value back in this new field I called "TestMe" with either a "0" or a "1"
for all my rows of data (all be it only 2 rows/records). However when I
enter a 1 in the dialog I get back record 1 and if I type 0 I get record 2
back, anything else I type I get nothing.
Help me to understand what I am doing wrong here.
many thanks
Macroman 3 1222
Macroman:
I just created a table like yours and ran a query with your IIF
statement and it ran just fine. Sometimes, Access gets weird and
exiting the db and reopening it will sometimes fix that issue.
HTH,
Jana
Macroman:
Just realized what might be wrong!
The whole line should look exactly like this:
TestMe: IIf([TestTable]![Field 1] Like "*" & [TestTable]![Field 2] &
"*",1,0)
My guess is yours looks like this:
Expr1:[TestMe] IIf([TestTable]![Field 1] Like "*" & [TestTable]![Field
2] & "*",1,0)
Delete the Expr1, delete the brackets around TestMe, and put it BEFORE
the colon.
That should do it!
Jana
Macroman wrote: Totally new to MS Access but kind of finding my way around I tried something simple and it is becomming a pain.
I created a simple table as follows
Field 1 = "This is Fred" , "This is George"
Why do this when you have their name in field 2?
Field 2 = "Fred" , "Adam" Field 3 = 1 , 2 Field 4 = 01/04/05 , 05/05/05
The comma separates the 2 rows of data I entered.
I then created a Query (all using the Design mode not quite comfortable with SQL yet) A query was simple enough , just dragged all the fields 1 to 4 down, then I thought I try to create an extra field using the "Build" option on the Criteria and wrote the syntax via "Built in Functions", the field name became "Expr1: [TestMe]" the syntax I built as follows
IIf([TestTable]![Field 1] Like "*" & [TestTable]![Field 2] & "*",1,0)
What I was attempting to do was simply say that if Field 1 is LIKE value in Field 2 then 1 else 0,
Why? You should be deriving field1 from the value in field2.
ie. Don't store "This is Fred"... build the string ="This is " &
[Field2] when you need the text.
what the damn thing is doing is giving me an "Enter Parameter Value" dialog box, which is what I do not want , I expected to get a value back in this new field I called "TestMe" with either a "0" or a "1" for all my rows of data (all be it only 2 rows/records). However when I enter a 1 in the dialog I get back record 1 and if I type 0 I get record 2 back, anything else I type I get nothing. Help me to understand what I am doing wrong here.
If you'd designed your tables correctly I suspect you wouldn't have to
be doing this to start with! :)
IIf([TestTable]![Field 1] Like "*" & [TestTable]![Field 2] & "*",1,0)
You need to put quotes around the resulting string after the LIKE:
Access needs to see something like:
[Field] Like "*value*"
What's you are passing is:
[Field] Like *value*
Access thinks *value* must be a parameter as it doesn't interpret it as
a string.
So it should be:
IIf([TestTable]![Field 1] Like "'*" & [TestTable]![Field 2] & "'*", 1,
0)
--
regards,
Bradley
A Christian Response http://www.pastornet.net.au/response This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Stijn Goris |
last post by:
hi all,
I cannot pass the of(move_uploaded_file($_FILES,
$uploaddir . $_FILES)) statemet and need some more
clear errorhandling besides the TRUE FALSE story. Can PHP telll me more in
detail why...
|
by: |
last post by:
If I need to check if a certain value does exist in a field, and return
either "yes" or "not" which query would be the most effestive?
|
by: Dmitri |
last post by:
I just looked at a coworker's stored procedure and this person is
dropping 4 Foreign key constraints and then re-adding them after
processing the required logic (updating rows in the 4 tables in...
|
by: Elroyskimms |
last post by:
Using SQL 2000...
tblCustomer:
CustomerID int
CompanyName varchar(20)
HasRetailStores bit
HasWholesaleStores bit
HasOtherStores bit
tblInvoiceMessages:
|
by: Ryan |
last post by:
I want to do the following SQL statement in Access. However, it won't
allow me to have the secondary part of my join statement and tells me
that this is not supported. OK, so Access doesn't support...
|
by: tz |
last post by:
The statement below is resulting in this error:
C:\Documents and Settings\Teddy\My Documents\Visual Studio
Projects\Calendar\Calendar.cs(181): Operator '&&' cannot
be applied to operands of type...
|
by: Josh Close |
last post by:
Is there a way to remove idle connections? My postgres server is
getting serveral hundred idle connections. It's due to a postgres .NET
provider not closing the connections properly. I don't want...
|
by: Mamidinx |
last post by:
Hi,
With the MERGE statement I am using in DB2 it rolls back all the way if
an error is encountered. Is there a way to save each of the encountered
exception but proceed to the next data record...
|
by: kimbred |
last post by:
Can someone tell me what I'm doing wrong here? I'm trying to get this method to return the seqnbr.
public override int GetSeqNbr(int EmpId)
{
DataSet ds = new...
|
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...
|
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...
|
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...
|
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,...
|
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: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
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,...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |