Hi,
I have the following SQL append query which works fine:
I need to convert this SQL to VBA and so far have the following:
After some debugging and trial and error it all works fine except the AS part: " & Me.QuoteID & " AS QuoteNumber " &
This is picking up the number in the QuoteID field on the loaded form and allocating it to the QuoteNumber Field for each record appended.
Can anyone see what I am doing wrong?
Thanks
I have the following SQL append query which works fine:
Code:
INSERT INTO [Quote Details] ( ProductID, ProductCode, ProductSFACode, UnitPrice, Quantity, Markup, QuoteID )
SELECT QuotationTemplatesDetails.ProductID, QuotationTemplatesDetails.ProductCode, QuotationTemplatesDetails.ProductSFACode, QuotationTemplatesDetails.UnitPrice, QuotationTemplatesDetails.Quantity, QuotationTemplatesDetails.Markup, [Forms]![Quotes]![QuoteID] AS QuoteNumber
FROM QuotationTemplatesDetails
WHERE (((QuotationTemplatesDetails.QuoteID)=[Forms]![Quotes]![txtTemplateNumber]));
I need to convert this SQL to VBA and so far have the following:
Code:
CurrentDb.Execute "INSERT INTO [Quote Details] ( ProductID, ProductCode, ProductSFACode, UnitPrice, Quantity, Markup, QuoteID ) " & _
" SELECT QuotationTemplatesDetails.ProductID, QuotationTemplatesDetails.ProductCode, QuotationTemplatesDetails.ProductSFACode, QuotationTemplatesDetails.UnitPrice, QuotationTemplatesDetails.Quantity, QuotationTemplatesDetails.Markup, " & Me.QuoteID & " AS QuoteNumber " & _
" FROM QuotationTemplatesDetails " & _
" WHERE (((QuotationTemplatesDetails.QuoteID)=" & Me.txtTemplateNumber & "));"
After some debugging and trial and error it all works fine except the AS part: " & Me.QuoteID & " AS QuoteNumber " &
This is picking up the number in the QuoteID field on the loaded form and allocating it to the QuoteNumber Field for each record appended.
Can anyone see what I am doing wrong?
Thanks