Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

replacing constants in a string

Status
Not open for further replies.

primerov

Technical User
Aug 16, 2002
160
BG
Can somebody help me in replacing some parts of a string with constants?

I will show at first the record source i have and then how i want to change it

The current record source is as follows


Dim Acc as string
Acc = " SELECT DISTINCTROW Orders.paymentid, Orders.invoicedate, Orders.PaymentMethodID,

Customers.Customerid, Customers.CompanyName, products.Productid, products.grade, products.code,

[order details].UnitPrice, [order details].Quantity, Customers.afid, Customers.kindid, Customers.bulstat,

Customers.taxid " & _
" FROM products INNER JOIN (Customers RIGHT JOIN (Orders INNER JOIN [order details] ON

Orders.orderid = [order details].OrderID) ON Customers.Customerid = Orders.customerid) ON

products.Productid = [order details].ProductID " & _
" WHERE (((Orders.paymentid) = True) And ((Year([invoicedate])) = 2003) And ((month([invoicedate])) = 1))

ORDER BY Orders.invoicedate;"
==================

Now i want to replace as follows
Dim Jahr As String Jahr = And ((Year([invoicedate])) = 2003)
Dim Monat As String Monat = And ((month([invoicedate])) = 1))
and the string part under question to read:

" WHERE (((Orders.paymentid) = True) & Jahr & Monat & ORDER BY Orders.invoicedate;"



I get a syntax error and i understand somewhere there is a mistake in my code.








 
You need to have your literals and variables separated. Add the additional quotes as below.

" WHERE (((Orders.paymentid) = True) " & Jahr & Monat & " ORDER BY Orders.invoicedate;"
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top