I need to code a new field (FieldRep)in my Access database based on the values in another field (Sample). If the value in Sample ends with "R", then FieldRep = "FR"; otherwise FieldRep = "#". But I keep getting the " Syntax Error (Comma) in query expression" message. Can anyone tell me which comma is causing the error (or if I'm missing a comma)?
Here's my query: - FieldRep: IIf(Right([Sample],1)="R","FR","#")
Here's an example of how the values in Sample look:
HB13_02
HB13_16
HB13_02R
HB13_16R
Thank you.
8 2744 jimatqsi 1,271
Recognized Expert Top Contributor
kbarrett,
Is the field being probed "Sample" or "SampleID"? Your code shows the latter but your question mentions the former twice.
Are there other fields in your query? It would be helpful to post the entire query source, if indeed this is part of a query. If so,go into SQL view mode of the query and copy the query text. Post it here. Be sure to use code tags (click the [Code/] button and paste your code between the tags).
Jim
Yes - I realized I initially posted the query with the wrong field name so I edited my post. The correct field name is "Sample".
Here is how the query looks in Design View:
FieldRep: IIf(Right([Sample],1)="R","FR","#")
Here is the SQL Code: - SELECT [Project name]+" 2013" AS StudyName, "Joe Graham (WDNR)" AS Contact, a_edd.Sample AS StationID, ['' ] AS Alternate_ID, a_edd.Sample AS LOCDESC, "R" AS EST_STN, a_edd.[Field ID] AS SampleID, IIf(Right([Sample],1)="R","FR","#") AS FieldRep, [CORE LOG XYZ_VALUES].Long_DD_NAD83 AS LongDD_83, [CORE LOG XYZ_VALUES].Lat_DD_NAD83 AS LatDD_83, [Upper Collection Depth]*2.54 AS [UDEPTH_(cm)], [Lower Collection Depth]*2.54 AS [LDEPTH_(cm)], [CORE LOG XYZ_VALUES].Time AS SAMPTIME, [CORE LOG XYZ_VALUES].Collected AS SAMPDATE, a_edd.[Analyte name] AS CHEMNAME, a_edd.Units, a_edd.[Lab Rep] AS LAB_MTHD_DUP, a_edd.[Final Qualifier] AS Final_QUALCODE, a_edd.Result AS CONC, a_edd.[Detection limit] AS MDL, a_edd.[Reporting limit] AS RL, a_edd.[Dilution factor] AS Dil_Factor, a_edd.[Analytical method] AS Analytical_Method, a_edd.[Lab name] AS Lab_Name, a_edd.[Measurement Basis] AS MEASBASIS
-
FROM a_edd, a_samplemaster, a_station, [CORE LOG XYZ_VALUES];
-
KBarrett
jimatqsi 1,271
Recognized Expert Top Contributor
This looks wrong
['' ] AS Alternate_ID,
If you're trying to make Alternate_ID a hard-coded space, just ' ' without the [] will work fine.
Jim
Is that what is causing the syntax error to occur?
jimatqsi 1,271
Recognized Expert Top Contributor
I get an error but I don't get an error message mentioning "comma"; so yes,it looks like an error from here.
NeoPa 32,557
Recognized Expert Moderator MVP
I see absolutely nothing wrong with the original code for [FieldRep], so it looks like the problem is elsewhere as Jim indicated.
Curious why you would have focused on FieldRep in spite of there being nothing to indicate it had a problem?
I assume it was FieldRep because that was the last edit I made after which the error message appears. I just tested by removing that column and the query runs successfully. However your suggestion to look elsewhere is worth checking. Thanks
NeoPa 32,557
Recognized Expert Moderator MVP
Let us know what you find.
Your reasoning makes sense. I see nothing wrong and I doubt I'm mistaken, but it can happen.
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Michael Turner |
last post by:
Hi
Can anyone help me with my syntax please. This is not working.
Set rs = conn.Execute("SELECT * FROM tblCompany WHERE company like '*" &
txt_search & "*';")
Thanks in advance
Mick
|
by: damian birchler |
last post by:
What's wrong about this:
22: static void (*)(void) instruction_table = {
jnz,
halt,
mv,
add,
mul,
mv_reg,
add_reg,
|
by: Nate |
last post by:
I am trying to use the following IF statement, and whenever I use a
single or double quote, I receive a syntax error. When using no
quotes, the syntax is accepted, but the statement does not...
|
by: sharmilah |
last post by:
I have the following code in my script and it's giving a syntax error at line *** when using the password function. My password in the mysql database is encrypted using the password function itself...
|
by: mutaher |
last post by:
geography(name, region, area, population, gdp)
Table Name = Geography
Column Name = Name, Region, Area, Population, GDP
Help me execute this statement
List the name and region of countries...
| |
by: maxamis4 |
last post by:
Hello folks,
Learning PHP here and I am using sendmail.php to send an email. I have setup my html contact form and I am using the following to send an email once a confirmation has been made:
...
|
by: James Watson |
last post by:
'Microsoft VB 6.3, Access 2002
'Syntax error in the INSERT INTO Statement when the query runs
'How can I make this work?
Private Sub Command52_Click()
On Error GoTo Err_Command52_Click
...
|
by: Bauklotz |
last post by:
So, recently I've been experimenting with a telnet server, and a 5250 terminal emutator and I thought of making a field system, for easier graphical (well, not quite) displaying.
This basically...
|
by: Jo Ann Dullum |
last post by:
I have a project and budget database that requires everything to be tied back to a unique projectID. The project table is tied to a Budget table (FK). When a budget entry is added, this creates a...
|
by: Grant Andrews |
last post by:
I an adding data into an access table via c# and have run into a roadblock. The syntax is
addSQL = "INSERT INTO history (, , , , , ) VALUES ('" + thisid + "','" + chat.DialogPartner + "','" +...
|
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,...
| |
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: 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...
|
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: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |