From: Jim on
just in case anyone else had a similar question, I figured this out by
mimicking the code in another database that uses an append sql statement

Mine goes as such:
dim strsql as string
strsql = "INSERT INTO tblPayRollSub ( Employee, PayrollID )" _
& "SELECT Employees.EmpName, (forms!frmpayrollheader!prheaderid) AS PR_ID" _
& "FROM Employees" _
& "WHERE (((Employees.Status) = strstat) And ((Employees.Type) = strtype))"
_
& "ORDER BY Employees.EmpName;"


Cheers,





"Jim" <jimt(a)pioneers.ca> wrote in message
news:YLgbk.54553$Jx.51601(a)pd7urf1no...
> anyone know how to run an append (well any query I suppose) from code.
>
> I'm rusty and actually have never ran a query from code.
>
> I'm thinking docmd.runquery("query")
>
> TIA
>
>


From: Arch on
On Fri, 04 Jul 2008 04:04:08 GMT, "Jim" <jimt(a)pioneers.ca> wrote:

>just in case anyone else had a similar question, I figured this out by
>mimicking the code in another database that uses an append sql statement
>
>Mine goes as such:
>dim strsql as string
>strsql = "INSERT INTO tblPayRollSub ( Employee, PayrollID )" _
>& "SELECT Employees.EmpName, (forms!frmpayrollheader!prheaderid) AS PR_ID" _
>& "FROM Employees" _
>& "WHERE (((Employees.Status) = strstat) And ((Employees.Type) = strtype))"
>_
>& "ORDER BY Employees.EmpName;"
>
>
>Cheers,
>

I predict you're going to have problems with that. Just exactly what
are strstat and strtype?


From: Jim on
Your prediciton is bang on!, I have egg on my face now.

It doesn't work. Says something about "query input needing at least one
table or query"

strStat and StrType are just string variables that I hard coded so I could
avoid the "quotes" issues.

I'm stuck now! I should have tested it before I ran off at the mouth.




"Arch" <send.no(a)spam.net> wrote in message
news:lo8r649s3ujacm59mn5tf7tvd6kmu7gapk(a)4ax.com...
> On Fri, 04 Jul 2008 04:04:08 GMT, "Jim" <jimt(a)pioneers.ca> wrote:
>
>>just in case anyone else had a similar question, I figured this out by
>>mimicking the code in another database that uses an append sql statement
>>
>>Mine goes as such:
>>dim strsql as string
>>strsql = "INSERT INTO tblPayRollSub ( Employee, PayrollID )" _
>>& "SELECT Employees.EmpName, (forms!frmpayrollheader!prheaderid) AS PR_ID"
>>_
>>& "FROM Employees" _
>>& "WHERE (((Employees.Status) = strstat) And ((Employees.Type) =
>>strtype))"
>>_
>>& "ORDER BY Employees.EmpName;"
>>
>>
>>Cheers,
>>
>
> I predict you're going to have problems with that. Just exactly what
> are strstat and strtype?
>
>


From: KC-Mass on
Would this work for you?
& "WHERE (((Employees.Status) = " & "'" & strstat & "'" & ") And
((Employees.Type) = " & "'" & strtype & "'" & "))"



"Jim" <jimt(a)pioneers.ca> wrote in message
news:Kwhbk.54638$Jx.27308(a)pd7urf1no...
> Your prediciton is bang on!, I have egg on my face now.
>
> It doesn't work. Says something about "query input needing at least one
> table or query"
>
> strStat and StrType are just string variables that I hard coded so I could
> avoid the "quotes" issues.
>
> I'm stuck now! I should have tested it before I ran off at the mouth.
>
>
>
>
> "Arch" <send.no(a)spam.net> wrote in message
> news:lo8r649s3ujacm59mn5tf7tvd6kmu7gapk(a)4ax.com...
>> On Fri, 04 Jul 2008 04:04:08 GMT, "Jim" <jimt(a)pioneers.ca> wrote:
>>
>>>just in case anyone else had a similar question, I figured this out by
>>>mimicking the code in another database that uses an append sql statement
>>>
>>>Mine goes as such:
>>>dim strsql as string
>>>strsql = "INSERT INTO tblPayRollSub ( Employee, PayrollID )" _
>>>& "SELECT Employees.EmpName, (forms!frmpayrollheader!prheaderid) AS
>>>PR_ID" _
>>>& "FROM Employees" _
>>>& "WHERE (((Employees.Status) = strstat) And ((Employees.Type) =
>>>strtype))"
>>>_
>>>& "ORDER BY Employees.EmpName;"
>>>
>>>
>>>Cheers,
>>>
>>
>> I predict you're going to have problems with that. Just exactly what
>> are strstat and strtype?
>>
>>
>
>


From: Jim on
I'll give it a try in the name of curiousity to get the sql stuff to work. I
did finally find out a way to run a query from code with the command button
wizard. It couldn't be simpler. When I invoked the command button wizard,
under miscellaneous operations, there was a "run a query" option.

But, I should persist in trying to make this run SQL work to, as I may need
to use variables some day and runSQL looks for efficient in that sense.

Thanks all.



"KC-Mass" <connearneyATcomcastDOTnet> wrote in message
news:rP-dnbdhp-Igl_PVnZ2dnUVZ_jCdnZ2d(a)comcast.com...
> Would this work for you?
> & "WHERE (((Employees.Status) = " & "'" & strstat & "'" & ") And
> ((Employees.Type) = " & "'" & strtype & "'" & "))"
>
>
>
> "Jim" <jimt(a)pioneers.ca> wrote in message
> news:Kwhbk.54638$Jx.27308(a)pd7urf1no...
>> Your prediciton is bang on!, I have egg on my face now.
>>
>> It doesn't work. Says something about "query input needing at least one
>> table or query"
>>
>> strStat and StrType are just string variables that I hard coded so I
>> could avoid the "quotes" issues.
>>
>> I'm stuck now! I should have tested it before I ran off at the mouth.
>>
>>
>>
>>
>> "Arch" <send.no(a)spam.net> wrote in message
>> news:lo8r649s3ujacm59mn5tf7tvd6kmu7gapk(a)4ax.com...
>>> On Fri, 04 Jul 2008 04:04:08 GMT, "Jim" <jimt(a)pioneers.ca> wrote:
>>>
>>>>just in case anyone else had a similar question, I figured this out by
>>>>mimicking the code in another database that uses an append sql statement
>>>>
>>>>Mine goes as such:
>>>>dim strsql as string
>>>>strsql = "INSERT INTO tblPayRollSub ( Employee, PayrollID )" _
>>>>& "SELECT Employees.EmpName, (forms!frmpayrollheader!prheaderid) AS
>>>>PR_ID" _
>>>>& "FROM Employees" _
>>>>& "WHERE (((Employees.Status) = strstat) And ((Employees.Type) =
>>>>strtype))"
>>>>_
>>>>& "ORDER BY Employees.EmpName;"
>>>>
>>>>
>>>>Cheers,
>>>>
>>>
>>> I predict you're going to have problems with that. Just exactly what
>>> are strstat and strtype?
>>>
>>>
>>
>>
>
>