B
Bonnie
Hello everyone! Using A02 on XP. Not a programmer but lovin' learnin'!
I have a little DB that I'm using to import .txt file from our system,
replace SSN's with "000000000" and add an AutoNum ID field (for privacy
issues) then spit out .xls file to a client for editing, we then import the
returned edited file, and then I need to reinsert the SSN's and export the
edited data to a .csv file to be loaded into our system. I've learned how to
use macros to import the file (named GPXXXX.txt) in a special folder that is
named the same as the contract number field on my form plus add the text
"Copy" or "Revised" to the table name when it is imported. So I'll end up
with 2 tables in my DB, one is GP1992Copy (pre-edit) and the other
GP1992Revised (post-edit).
First, my compare query (see below) needs to check the SSN fields and IF SSN
= "000000000" use GP1992Copy.SSN ELSE use GP1992Revised.SSN. So all SSN's
should end up in a field called [Social]. All records sent SSN field will
equal "000000000" but if the client adds new records, the SSN field will
contain a real SSN and I need that. So this will combine the 2 fields to one
IF they have a real SSN. I used the ID field to link. I've created an SQL
that will do it if I name the tables. I want to insert the variable wordage
that I have added below the SQL.
SELECT GP1992Revised.ID, GP1992Copy.SSN, GP1992Revised.SSN,
IIf(([GP1992Revised]![SSN])="000000000",[GP1992Copy]![SSN],[GP1992Revised]![SSN])
AS Social, GP1992Revised.[First Name], GP1992Revised.[Last Name],
GP1992Revised.Gender, GP1992Revised.[Date of Birth], GP1992Revised.[Date of
Hire], GP1992Revised.Hours, GP1992Revised.Compensation,
GP1992Revised.[Deferral Amount], GP1992Revised.[Excludable Compensation],
GP1992Revised.[Section 125], GP1992Revised.[Status Code],
GP1992Revised.[Status Date]
FROM GP1992Copy RIGHT JOIN GP1992Revised ON GP1992Copy.ID = GP1992Revised.ID
WITH OWNERACCESS OPTION;
These are the two tables that should be used if I can get it to work.
[Forms]![fCensus1Conversion]![RunThisOne] & "Copy" (ex. GP1992Copy)
[Forms]![fCensus1Conversion]![RunThisOne] & "Revised" (ex. GP1992Revised)
I replaced the items with this:
SELECT [Forms]![fCensus1Conversion]![RunThisOne] & "Revised".ID,
[Forms]![fCensus1Conversion]![RunThisOne] & "Copy".SSN,
[Forms]![fCensus1Conversion]![RunThisOne] & "Revised".SSN,
IIf(([Forms]![fCensus1Conversion]![RunThisOne] &
"Revised"![SSN])="000000000",[Forms]![fCensus1Conversion]![RunThisOne] &
"Copy"![SSN],[Forms]![fCensus1Conversion]![RunThisOne] & "Revised"![SSN]) AS
Social, [Forms]![fCensus1Conversion]![RunThisOne] & "Revised".[First Name],
[Forms]![fCensus1Conversion]![RunThisOne] & "Revised".[Last Name],
[Forms]![fCensus1Conversion]![RunThisOne] & "Revised".Gender,
[Forms]![fCensus1Conversion]![RunThisOne] & "Revised".[Date of Birth],
[Forms]![fCensus1Conversion]![RunThisOne] & "Revised".[Date of Hire],
[Forms]![fCensus1Conversion]![RunThisOne] & "Revised".Hours,
[Forms]![fCensus1Conversion]![RunThisOne] & "Revised".Compensation,
[Forms]![fCensus1Conversion]![RunThisOne] & "Revised".[Deferral Amount],
[Forms]![fCensus1Conversion]![RunThisOne] & "Revised".[Excludable
Compensation], [Forms]![fCensus1Conversion]![RunThisOne] & "Revised".[Section
125], [Forms]![fCensus1Conversion]![RunThisOne] & "Revised".[Status Code],
[Forms]![fCensus1Conversion]![RunThisOne] & "Revised".[Status Date]
FROM [Forms]![fCensus1Conversion]![RunThisOne] & "Copy" RIGHT JOIN
[Forms]![fCensus1Conversion]![RunThisOne] & "Revised" ON
[Forms]![fCensus1Conversion]![RunThisOne] & "Copy".ID =
[Forms]![fCensus1Conversion]![RunThisOne] & "Revised".ID
WITH OWNERACCESS OPTION;
But when I run it I get an error: Syntax Error in From Clause
I'm sure it's something simple. I would really appreciate any help or
advice. Thanks in advance for your time.
I have a little DB that I'm using to import .txt file from our system,
replace SSN's with "000000000" and add an AutoNum ID field (for privacy
issues) then spit out .xls file to a client for editing, we then import the
returned edited file, and then I need to reinsert the SSN's and export the
edited data to a .csv file to be loaded into our system. I've learned how to
use macros to import the file (named GPXXXX.txt) in a special folder that is
named the same as the contract number field on my form plus add the text
"Copy" or "Revised" to the table name when it is imported. So I'll end up
with 2 tables in my DB, one is GP1992Copy (pre-edit) and the other
GP1992Revised (post-edit).
First, my compare query (see below) needs to check the SSN fields and IF SSN
= "000000000" use GP1992Copy.SSN ELSE use GP1992Revised.SSN. So all SSN's
should end up in a field called [Social]. All records sent SSN field will
equal "000000000" but if the client adds new records, the SSN field will
contain a real SSN and I need that. So this will combine the 2 fields to one
IF they have a real SSN. I used the ID field to link. I've created an SQL
that will do it if I name the tables. I want to insert the variable wordage
that I have added below the SQL.
SELECT GP1992Revised.ID, GP1992Copy.SSN, GP1992Revised.SSN,
IIf(([GP1992Revised]![SSN])="000000000",[GP1992Copy]![SSN],[GP1992Revised]![SSN])
AS Social, GP1992Revised.[First Name], GP1992Revised.[Last Name],
GP1992Revised.Gender, GP1992Revised.[Date of Birth], GP1992Revised.[Date of
Hire], GP1992Revised.Hours, GP1992Revised.Compensation,
GP1992Revised.[Deferral Amount], GP1992Revised.[Excludable Compensation],
GP1992Revised.[Section 125], GP1992Revised.[Status Code],
GP1992Revised.[Status Date]
FROM GP1992Copy RIGHT JOIN GP1992Revised ON GP1992Copy.ID = GP1992Revised.ID
WITH OWNERACCESS OPTION;
These are the two tables that should be used if I can get it to work.
[Forms]![fCensus1Conversion]![RunThisOne] & "Copy" (ex. GP1992Copy)
[Forms]![fCensus1Conversion]![RunThisOne] & "Revised" (ex. GP1992Revised)
I replaced the items with this:
SELECT [Forms]![fCensus1Conversion]![RunThisOne] & "Revised".ID,
[Forms]![fCensus1Conversion]![RunThisOne] & "Copy".SSN,
[Forms]![fCensus1Conversion]![RunThisOne] & "Revised".SSN,
IIf(([Forms]![fCensus1Conversion]![RunThisOne] &
"Revised"![SSN])="000000000",[Forms]![fCensus1Conversion]![RunThisOne] &
"Copy"![SSN],[Forms]![fCensus1Conversion]![RunThisOne] & "Revised"![SSN]) AS
Social, [Forms]![fCensus1Conversion]![RunThisOne] & "Revised".[First Name],
[Forms]![fCensus1Conversion]![RunThisOne] & "Revised".[Last Name],
[Forms]![fCensus1Conversion]![RunThisOne] & "Revised".Gender,
[Forms]![fCensus1Conversion]![RunThisOne] & "Revised".[Date of Birth],
[Forms]![fCensus1Conversion]![RunThisOne] & "Revised".[Date of Hire],
[Forms]![fCensus1Conversion]![RunThisOne] & "Revised".Hours,
[Forms]![fCensus1Conversion]![RunThisOne] & "Revised".Compensation,
[Forms]![fCensus1Conversion]![RunThisOne] & "Revised".[Deferral Amount],
[Forms]![fCensus1Conversion]![RunThisOne] & "Revised".[Excludable
Compensation], [Forms]![fCensus1Conversion]![RunThisOne] & "Revised".[Section
125], [Forms]![fCensus1Conversion]![RunThisOne] & "Revised".[Status Code],
[Forms]![fCensus1Conversion]![RunThisOne] & "Revised".[Status Date]
FROM [Forms]![fCensus1Conversion]![RunThisOne] & "Copy" RIGHT JOIN
[Forms]![fCensus1Conversion]![RunThisOne] & "Revised" ON
[Forms]![fCensus1Conversion]![RunThisOne] & "Copy".ID =
[Forms]![fCensus1Conversion]![RunThisOne] & "Revised".ID
WITH OWNERACCESS OPTION;
But when I run it I get an error: Syntax Error in From Clause
I'm sure it's something simple. I would really appreciate any help or
advice. Thanks in advance for your time.