i would like to do an append query and would like to include both data from an existing table and variable assigned in my VB code. Is this possible, as i am getting an error message saying:
"Number of query values and destination fields aren't the same"
my code is:
Private Sub cmdFullRun_Click()
Dim msg As String
Dim Letter As String
Dim Data As String
Dim LetterType As String
Dim AccessApp As Access.Application
Dim DBPath As String
Dim DropMacro As String
Dim todays_date As Date
todays_date = Date
LetterType = Left(lblLetterType.Caption, 3)
DropMacro = Left(LetterType, 3)
DBPath = "C:\My Documents\darryl.mdb"
Set AccessApp = New Access.Application
With AccessApp
.OpenCurrentDatabase DBPath
.DoCmd.RunSQL "INSERT INTO letter_history ( letter_type, account_no, arrears_amount, todays_date) SELECT letter_type, account_no, arrears_amount FROM LetterSelection"
.DoCmd.RunMacro ("warnings off"
.DoCmd.RunSQL ("Select * into output from LetterSelection"
.DoCmd.RunMacro ("Export"
.DoCmd.RunSQL ("drop table output"
.DoCmd.RunMacro ("warnings on"
.CloseCurrentDatabase
End With
'Letter = "C:\darryl\uni work\project\" & LetterType & "Letter.doc"
'Data = "C:\my documents\darryl.txt"
'msg = FireUpWord(Letter, _
Data)
'If msg <> "" Then MsgBox msg
End Sub
"Number of query values and destination fields aren't the same"
my code is:
Private Sub cmdFullRun_Click()
Dim msg As String
Dim Letter As String
Dim Data As String
Dim LetterType As String
Dim AccessApp As Access.Application
Dim DBPath As String
Dim DropMacro As String
Dim todays_date As Date
todays_date = Date
LetterType = Left(lblLetterType.Caption, 3)
DropMacro = Left(LetterType, 3)
DBPath = "C:\My Documents\darryl.mdb"
Set AccessApp = New Access.Application
With AccessApp
.OpenCurrentDatabase DBPath
.DoCmd.RunSQL "INSERT INTO letter_history ( letter_type, account_no, arrears_amount, todays_date) SELECT letter_type, account_no, arrears_amount FROM LetterSelection"
.DoCmd.RunMacro ("warnings off"
.DoCmd.RunSQL ("Select * into output from LetterSelection"
.DoCmd.RunMacro ("Export"
.DoCmd.RunSQL ("drop table output"
.DoCmd.RunMacro ("warnings on"
.CloseCurrentDatabase
End With
'Letter = "C:\darryl\uni work\project\" & LetterType & "Letter.doc"
'Data = "C:\my documents\darryl.txt"
'msg = FireUpWord(Letter, _
Data)
'If msg <> "" Then MsgBox msg
End Sub