R
rebelscum0000
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
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