A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Running & Setting Up Queries
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Query behaving differently in VBA than when running as regular Que



 
 
Thread Tools Display Modes
  #1  
Old February 5th, 2010, 10:08 PM posted to microsoft.public.access.queries
bvdahl
external usenet poster
 
Posts: 23
Default Query behaving differently in VBA than when running as regular Que

Hello,

I have been struggeling with this problem the whole day, and I hope some one
can give me some insight. I have an INSERT query that I want to run from VBA,
but when I do that, I get the errormessage : "This Recordset is not
updatable. (Error 3326)"

The strange part is that when I run it as a regular query, I have no
problems. The query is based on tables that are linked to a postgrSQL. I
don't know if it is relevant or not, but just so you know.

Here are the two statements. First the VBA one:

Dim nlhe_largest As String

nlhe_largest = "INSERT INTO temp_largest_pots ( screen_name, pot_size,
game, final_hand, hole_cards, hand_history )" _
& " SELECT TOP 25 nlhe_players.screen_name, nlhe_game_players.total_won,
nlhe_game_blinds.game_level_desc, nlhe_game_players.final_hand,
nlhe_game_players.hole_cards, nlhe_hand_histories.hand_history" _
& " FROM (nlhe_players INNER JOIN ((nlhe_game_players INNER JOIN
nlhe_game ON nlhe_game_players.game_id = nlhe_game.game_id) INNER JOIN
nlhe_hand_histories ON nlhe_game.game_number =
nlhe_hand_histories.game_number) ON nlhe_players.player_id =
nlhe_game_players.player_id) INNER JOIN nlhe_game_blinds ON
nlhe_game.game_level_id = nlhe_game_blinds.game_level_id" _
& " WHERE nlhe_game.date_played #" & Me.text_date_from & " " &
Me.text_time_from & " # And nlhe_game.date_played # " & Me.text_date_to & "
" & Me.text_time_to & " # nlhe_game_players.total_won 25000" _
& " ORDER BY nlhe_game_players.total_won DESC;"

DoCmd.RunSQL nlhe_largest

---------------------

INSERT INTO temp_largest_pots ( screen_name, pot_size, game, final_hand,
hole_cards, hand_history )
SELECT TOP 25 nlhe_players.screen_name, nlhe_game_players.total_won,
nlhe_game_blinds.game_level_desc, nlhe_game_players.final_hand,
nlhe_game_players.hole_cards, nlhe_hand_histories.hand_history
FROM (nlhe_players INNER JOIN ((nlhe_game_players INNER JOIN nlhe_game ON
nlhe_game_players.game_id=nlhe_game.game_id) INNER JOIN nlhe_hand_histories
ON nlhe_game.game_number=nlhe_hand_histories.game_num ber) ON
nlhe_players.player_id=nlhe_game_players.player_id ) INNER JOIN
nlhe_game_blinds ON nlhe_game.game_level_id=nlhe_game_blinds.game_leve l_id
WHERE (((nlhe_game_players.total_won)25000) AND
((nlhe_game.date_played)#1/1/2010# And (nlhe_game.date_played)#1/15/2010#))
ORDER BY nlhe_game_players.total_won DESC;

-------------------

Would be really greatful for some input

Baard


  #2  
Old February 6th, 2010, 12:18 AM posted to microsoft.public.access.queries
Duane Hookom[_4_]
external usenet poster
 
Posts: 316
Default Query behaving differently in VBA than when running as regular Que

You seem to have extra spaces around you date/time values and are missing "
AND " about he
& Me.text_time_to & " # nlhe_game_players.total_won 25000" _

Duane Hookom
MS Access MVP

"bvdahl" wrote in message
...
Hello,

I have been struggeling with this problem the whole day, and I hope some
one
can give me some insight. I have an INSERT query that I want to run from
VBA,
but when I do that, I get the errormessage : "This Recordset is not
updatable. (Error 3326)"

The strange part is that when I run it as a regular query, I have no
problems. The query is based on tables that are linked to a postgrSQL. I
don't know if it is relevant or not, but just so you know.

Here are the two statements. First the VBA one:

Dim nlhe_largest As String

nlhe_largest = "INSERT INTO temp_largest_pots ( screen_name, pot_size,
game, final_hand, hole_cards, hand_history )" _
& " SELECT TOP 25 nlhe_players.screen_name,
nlhe_game_players.total_won,
nlhe_game_blinds.game_level_desc, nlhe_game_players.final_hand,
nlhe_game_players.hole_cards, nlhe_hand_histories.hand_history" _
& " FROM (nlhe_players INNER JOIN ((nlhe_game_players INNER JOIN
nlhe_game ON nlhe_game_players.game_id = nlhe_game.game_id) INNER JOIN
nlhe_hand_histories ON nlhe_game.game_number =
nlhe_hand_histories.game_number) ON nlhe_players.player_id =
nlhe_game_players.player_id) INNER JOIN nlhe_game_blinds ON
nlhe_game.game_level_id = nlhe_game_blinds.game_level_id" _
& " WHERE nlhe_game.date_played #" & Me.text_date_from & " " &
Me.text_time_from & " # And nlhe_game.date_played # " & Me.text_date_to
& "
" & Me.text_time_to & " # nlhe_game_players.total_won 25000" _
& " ORDER BY nlhe_game_players.total_won DESC;"

DoCmd.RunSQL nlhe_largest

---------------------

INSERT INTO temp_largest_pots ( screen_name, pot_size, game, final_hand,
hole_cards, hand_history )
SELECT TOP 25 nlhe_players.screen_name, nlhe_game_players.total_won,
nlhe_game_blinds.game_level_desc, nlhe_game_players.final_hand,
nlhe_game_players.hole_cards, nlhe_hand_histories.hand_history
FROM (nlhe_players INNER JOIN ((nlhe_game_players INNER JOIN nlhe_game ON
nlhe_game_players.game_id=nlhe_game.game_id) INNER JOIN
nlhe_hand_histories
ON nlhe_game.game_number=nlhe_hand_histories.game_num ber) ON
nlhe_players.player_id=nlhe_game_players.player_id ) INNER JOIN
nlhe_game_blinds ON nlhe_game.game_level_id=nlhe_game_blinds.game_leve l_id
WHERE (((nlhe_game_players.total_won)25000) AND
((nlhe_game.date_played)#1/1/2010# And
(nlhe_game.date_played)#1/15/2010#))
ORDER BY nlhe_game_players.total_won DESC;

-------------------

Would be really greatful for some input

Baard


 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 08:24 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.