View Full Version : executing query in VB


rajat
01-10-2006, 05:21 AM
hi,

i was tryin 2 run this query in VB

Insert into Hourly_Count SELECT StoreNo, Date, Sum([12:00AM]) AS 12AM, Sum([1:00AM]) AS 1AM, Sum([2:00AM]) AS 2AM, Sum([3:00AM]) AS 3AM, Sum([4:00AM]) AS 4AM, Sum([5:00AM]) AS 5AM, Sum([6:00AM]) AS 6AM, Sum([7:00AM]) AS 7AM, Sum([8:00AM]) AS 8AM, Sum([9:00AM]) AS 9AM, Sum([10:00AM]) AS 10AM, Sum([11:00AM]) AS 11AM, Sum([12:00PM]) AS 12PM, Sum([1:00PM]) AS 1PM, Sum([2:00PM]) AS 2PM, Sum([3:00PM]) AS 3PM, Sum([4:00PM]) AS 4PM, Sum([5:00PM]) AS 5PM, Sum([6:00PM]) AS 6PM, Sum([7:00PM]) AS 7PM, Sum([8:00PM]) AS 8PM, Sum([9:00PM]) AS 9PM, Sum([10:00PM]) AS 10PM, Sum([11:00PM]) AS 11PM FROM TABLE_A where date between #7/25/2005# and #7/19/2005# and storeno=1 GROUP BY StoreNo, Date ORDER BY Date

using
db.OpenRecordset(ABOVE_QUERY_HERE)

i always get "invalid operation" error!!!

all i need is to execute this query....in any possible way.....
Above query works perfectly when run in access xp/2002

i am not used to work on access.....more customed to MS sql 2000.....but GOD access is IMPOSSIBLE!!!!

any HELP plz :confused: :confused: :confused:

namliam
01-10-2006, 05:25 AM
Access is far from impossible kind sir (Him or her offcourse ;))

Try doing db.execute instead.

Jibbadiah
01-10-2006, 06:32 AM
Don't think that you can run an insert query as part of a recordset?!

Any time I do an insert I use the following syntax.

Dim strSQL as string

strsql = "insert into tblTableName values ('It', 'is', 'this', 'easy');"

DoCmd.RunSQL strsql

rajat
01-11-2006, 03:11 AM
Access is far from impossible kind sir (Him or her offcourse ;))

:rolleyes: :rolleyes: :rolleyes: :rolleyes:


thanks for reply......

@Jibbadiah's soln worked.....

when i tried "db.execute", got Operation must use an updateable query error