PC Review


Reply
Thread Tools Rate Thread

I can not Execute Simple Append Query

 
 
rebelscum0000
Guest
Posts: n/a
 
      11th Dec 2006
Topic: I can't Execute Simple Append Query

Dear All,

My problem began when I moved my code from my Forms to a Module, since
then I am having several Errors

Can someone please help me to determinate what I am doing wrong in this
Action Query?

Do I need to Dim dbMyKeywordININ As Database and rstMyKeywordININ
DAO.Recordset?

Do I need to Dim CurrentDb?

My Code

Sub MyKeyword_InsertsINTO_Tbl_MyKeywords_Tbl()

Dim dbMyKeywordININ As Database 'Current Dbs Default Table My
Keywod INSERT INTO
Dim rstMyKeywordININ As DAO.Recordset 'DAO.Recordset My Kwyword INSERT
INTO
Dim sQL3 As String 'Query, Variables more
strongly
Dim MyKeywordDe As String 'My Keyword Default

'Make sure Microsoft DAO 3.6 Library in included in the References

'On Error GoTo ErrorHandling
'Initialize Variables
MyKeywordDe = Forms!MainExclude_Form!Keyword
MsgBox MyKeywordDe

'Action Query Append
sQL3 = _
"INSERT INTO MyKeywords_Tbl ( ID, MyKeyword ) " & _
"SELECT MainExclude_Tbl.MyKeyword.ID, MainExclude_Tbl.MyKeyword " & _
"FROM MainExclude_Tbl " & _
"WHERE (((MainExclude_Tbl.MyKeyword) = '" &
Forms!MainExclude_Form!Keyword & "' )) "

Debug.Print sQL3

CurrentDb.Execute sQL3, dbFailOnError

Exit Sub
'ErrorHandling:
'MsgBox "Error Number: " & Err & " Descripcion " & Err.Description
End Sub

 
Reply With Quote
 
 
 
 
Daniel
Guest
Posts: n/a
 
      11th Dec 2006
Hi,

The thing which jumps out at me is
> "SELECT MainExclude_Tbl.MyKeyword.ID, MainExclude_Tbl.MyKeyword " & _

because the first thing you're selecting doesn't look right. Maybe it
should be:
"SELECT MainExclude_Tbl.ID, MainExclude_Tbl.MyKeyword " & _

One thing which I find helpful is stepping through the code, and when
you get to the line where you generate your SQL statement, select the
SQL statement including quotation marks, and 'evaluate' it in the
immediate window. Then, paste the evaluated version into a new Query
and try to run it. The error messages are often helpful.

Daniel

rebelscum0000 wrote:
> Topic: I can't Execute Simple Append Query
>
> Dear All,
>
> My problem began when I moved my code from my Forms to a Module, since
> then I am having several Errors
>
> Can someone please help me to determinate what I am doing wrong in this
> Action Query?
>
> Do I need to Dim dbMyKeywordININ As Database and rstMyKeywordININ
> DAO.Recordset?
>
> Do I need to Dim CurrentDb?
>
> My Code
>
> Sub MyKeyword_InsertsINTO_Tbl_MyKeywords_Tbl()
>
> Dim dbMyKeywordININ As Database 'Current Dbs Default Table My
> Keywod INSERT INTO
> Dim rstMyKeywordININ As DAO.Recordset 'DAO.Recordset My Kwyword INSERT
> INTO
> Dim sQL3 As String 'Query, Variables more
> strongly
> Dim MyKeywordDe As String 'My Keyword Default
>
> 'Make sure Microsoft DAO 3.6 Library in included in the References
>
> 'On Error GoTo ErrorHandling
> 'Initialize Variables
> MyKeywordDe = Forms!MainExclude_Form!Keyword
> MsgBox MyKeywordDe
>
> 'Action Query Append
> sQL3 = _
> "INSERT INTO MyKeywords_Tbl ( ID, MyKeyword ) " & _
> "SELECT MainExclude_Tbl.MyKeyword.ID, MainExclude_Tbl.MyKeyword " & _
> "FROM MainExclude_Tbl " & _
> "WHERE (((MainExclude_Tbl.MyKeyword) = '" &
> Forms!MainExclude_Form!Keyword & "' )) "
>
> Debug.Print sQL3
>
> CurrentDb.Execute sQL3, dbFailOnError
>
> Exit Sub
> 'ErrorHandling:
> 'MsgBox "Error Number: " & Err & " Descripcion " & Err.Description
> End Sub


 
Reply With Quote
 
rebelscum0000
Guest
Posts: n/a
 
      11th Dec 2006
Dear Daniel,

Thank you very much!

Now it WORKS!!

Once again THANK YOU

Kind Regards,
Antonio Macias

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Move records from Append Query to Simple Query Stockwell43 Microsoft Access 4 24th Sep 2008 06:49 PM
execute append query =?Utf-8?B?ZGJiMTk3MEBob3RtYWlsLmNvbQ==?= Microsoft Access VBA Modules 13 4th Jan 2008 05:42 PM
Re: Third time asking, no solution yet, a simple append query Adam Microsoft Access 0 22nd Dec 2006 12:17 PM
RE: Third time asking, no solution yet, a simple append query =?Utf-8?B?emV5bmVkZGluZQ==?= Microsoft Access 0 21st Dec 2006 10:20 PM
Help with a simple append query Joe Cilinceon Microsoft Access Queries 2 11th Jan 2005 11:22 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 05:52 PM.