Group:  Microsoft Access ยป microsoft.public.access.formscoding
Thread: Modify sql statement

Geek News

Modify sql statement
Rod 12/10/2008 8:38:04 PM
Hello,

I and doing an archive and would like to make a simple change but can't
figure it out. Here is the code:

'Step 1: Initialize database object inside a transaction.
Set ws = DBEngine(0)
ws.BeginTrans
bInTrans = True
Set db = ws(0)

'Step 2: Execute the append.
strSql = "INSERT INTO tblCandidatesArchive "
strSql = strSql & " IN 'J:\Bak\PFS\Recruiting\MyCandidateArchiveTable.mdb' "
strSql = strSql & " SELECT * FROM tblCandidates"
strSql = strSql & " WHERE Archive <= #" & Date & "#;"

db.Execute strSql ', dbFailOnError

'Step 3: Execute the delete.
strSql = "DELETE FROM tblCandidates"
strSql = strSql & " WHERE Archive <= #" & Date & "#;"
db.Execute strSql ', dbFailOnError

I would like to change the WHERE statements to not only check the date but
if CALL_RESULTS = Skipped then archive that record as well.

Thanks.
RE: Modify sql statement
Dorian 12/10/2008 10:52:01 PM
[Quoted Text]
> strSql = "INSERT INTO tblCandidatesArchive "
> strSql = strSql & " IN 'J:\Bak\PFS\Recruiting\MyCandidateArchiveTable.mdb' "
> strSql = strSql & " SELECT * FROM tblCandidates"
> strSql = strSql & " WHERE Archive <= #" & Date & "#" & _
OR CALL_RESULTS = 'Skipped';"

> strSql = "DELETE FROM tblCandidates"
> strSql = strSql & " WHERE Archive <= #" & Date & "#" & _
OR CALL_RESULTS = 'Skipped';"

-- Dorian
"Give someone a fish and they eat for a day; teach someone to fish and they
eat for a lifetime".


"Rod" wrote:

> Hello,
>
> I and doing an archive and would like to make a simple change but can't
> figure it out. Here is the code:
>
> 'Step 1: Initialize database object inside a transaction.
> Set ws = DBEngine(0)
> ws.BeginTrans
> bInTrans = True
> Set db = ws(0)
>
> 'Step 2: Execute the append.
> strSql = "INSERT INTO tblCandidatesArchive "
> strSql = strSql & " IN 'J:\Bak\PFS\Recruiting\MyCandidateArchiveTable.mdb' "
> strSql = strSql & " SELECT * FROM tblCandidates"
> strSql = strSql & " WHERE Archive <= #" & Date & "#;"
>
> db.Execute strSql ', dbFailOnError
>
> 'Step 3: Execute the delete.
> strSql = "DELETE FROM tblCandidates"
> strSql = strSql & " WHERE Archive <= #" & Date & "#;"
> db.Execute strSql ', dbFailOnError
>
> I would like to change the WHERE statements to not only check the date but
> if CALL_RESULTS = Skipped then archive that record as well.
>
> Thanks.
RE: Modify sql statement
Rod 12/10/2008 11:33:00 PM
Thanks much!

"Dorian" wrote:

[Quoted Text]
> > strSql = "INSERT INTO tblCandidatesArchive "
> > strSql = strSql & " IN 'J:\Bak\PFS\Recruiting\MyCandidateArchiveTable.mdb' "
> > strSql = strSql & " SELECT * FROM tblCandidates"
> > strSql = strSql & " WHERE Archive <= #" & Date & "#" & _
> OR CALL_RESULTS = 'Skipped';"
>
> > strSql = "DELETE FROM tblCandidates"
> > strSql = strSql & " WHERE Archive <= #" & Date & "#" & _
> OR CALL_RESULTS = 'Skipped';"
>
> -- Dorian
> "Give someone a fish and they eat for a day; teach someone to fish and they
> eat for a lifetime".
>
>
> "Rod" wrote:
>
> > Hello,
> >
> > I and doing an archive and would like to make a simple change but can't
> > figure it out. Here is the code:
> >
> > 'Step 1: Initialize database object inside a transaction.
> > Set ws = DBEngine(0)
> > ws.BeginTrans
> > bInTrans = True
> > Set db = ws(0)
> >
> > 'Step 2: Execute the append.
> > strSql = "INSERT INTO tblCandidatesArchive "
> > strSql = strSql & " IN 'J:\Bak\PFS\Recruiting\MyCandidateArchiveTable.mdb' "
> > strSql = strSql & " SELECT * FROM tblCandidates"
> > strSql = strSql & " WHERE Archive <= #" & Date & "#;"
> >
> > db.Execute strSql ', dbFailOnError
> >
> > 'Step 3: Execute the delete.
> > strSql = "DELETE FROM tblCandidates"
> > strSql = strSql & " WHERE Archive <= #" & Date & "#;"
> > db.Execute strSql ', dbFailOnError
> >
> > I would like to change the WHERE statements to not only check the date but
> > if CALL_RESULTS = Skipped then archive that record as well.
> >
> > Thanks.

Home | Search | Terms | Imprint Contact
Newsgroups Reader - provided by WiredBox.Net