duplicate output destination 'date'

Gr3g0ry

Registered User.
Local time
Today, 03:25
Joined
Oct 12, 2017
Messages
163
Hey i keep getting this error and i cant seem to understand why. here is my code and query

Run-time Error '3063'
duplicate output destination 'date'


Private Sub Create_Click()

Dim StrSQL As String
Dim StrSQL2 As String

Dim TRN As String
Dim StartDate As Date
Dim MaturityDate As Date
Dim EndDate As Date
Dim PartnerId As Integer
Dim StartAmount As Double
Dim ActualBalance As Double
Dim MaturityBalance As Double
Dim Installments As Integer
Dim PaymentMethod As String

TRN = Me.cboTrn.Value
StartDate = Me.StartDate.Value
EndDate = DateAdd("m", 6, Me.StartDate.Value)
MaturityDate = Me.MaturityDate.Value
PartnerId = Me.PartnerId.Value
StartAmount = Me.StartAmount.Value
ActualBalance = Me.ActualBalance.Value
MaturitytBalance = Me.MaturityAmount.Value
Installments = Me.Installments.Value
PaymentMethod = Me.cboTerm.Value

DoCmd.RunSQL "INSERT INTO PARTNER (TRN,[date],[date],StartAmount,[date],ActualBalance,MaturityBalance,PaymentMethod,PartnerId,Installments) VALUES (" & TRN & ", #" & StartDate & "#, #" & EndDate & "#, " & StartAmount & ", #" & MaturityDate & "#, " & ActualBalance & ", " & MaturityBalance & ", " & PaymentMethod & ", " & PartnerId & ", " & Installments & ");"


'DoCmd.RunSQL "Insert into PAYMENTS (PartnerId,Amount,PaymentDate) VALUES ('" & PartnerId & "' '" & Amount & "' '" & StartDate & "')"


db.Close


End Sub
 
You are specifying the same field [date] three times in the field list.

Code:
DoCmd.RunSQL "INSERT INTO PARTNER (TRN,[date],[date],StartAmount,[date],

BTW Date is a reserved word best avoided for object names.
 
ok thanks. now to my other questions. how do i remedy this because i was of the impression that [date] was a typecast. do i just specify the variable names ?
 
RunSQL runs an SQLdatabase command. The field list in the INSERT query specifies the fieldnames in a table or query called PARTNER. The data types of the fields are not specified in the query.
 
sorry for being such a nub. i was waiting to ask that. does it work in vba like it does in most other languages where numbers are in single quotes and strings in double quotes ?

can u provide examples of queries in vba please ?

im tryna learn vba the hard way
 
ok so i got the query working now. but with another issue. now im getting another error.

Object Required.

and it points to

db.Close.

and ideas ?
 
ok so thanks and ive resolved all my issues. if i come across any other issues i will consult again
 

Users who are viewing this thread

Back
Top Bottom