Results 1 to 2 of 2
  1. #1
    Star Lounger
    Join Date
    Sep 2002
    Posts
    81
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Variable not accepted (Access 2000)

    In the OnOpern event of the form i have the following command:

    Dim InExtVa As String
    InExtVa = " SELECT products.Productid, products.grade, [order details].liters, orders.orderid, orders.orderdate, orders.orderdate " & _
    " FROM (orders INNER JOIN customers ON orders.customerid = customers.Customerid) INNER JOIN ([order details] INNER JOIN products ON [order

    details].ProductID = products.Productid) ON orders.orderid = [order details].OrderID " & _
    " WHERE (((Year([InvoiceDate])) = " & CnstYear & ") And ((orders.CustomerID) = 118)) ORDER BY products.grade"
    Me.RecordSource = InExtVa



    I want to imrpove it by creating a variable StrOffice like that

    Dim StrOffice As Integer
    StrOffice = 118

    And then repliacing it in the code:
    InExtVa = " SELECT products.Productid, products.grade, [order details].liters, orders.orderid, orders.orderdate, orders.orderdate " & _
    " FROM (orders INNER JOIN customers ON orders.customerid = customers.Customerid) INNER JOIN ([order details] INNER JOIN products ON [order

    details].ProductID = products.Productid) ON orders.orderid = [order details].OrderID " & _
    " WHERE (((Year([InvoiceDate])) = " & CnstYear & ") And ((orders.CustomerID) = StrOffice)) ORDER BY products.grade"


    My variable is not accepted.May i know the reason for my mistake?

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Variable not accepted (Access 2000)

    You have to do this the same way it was done for CnstYear: you have to place the variable StrOffice outside the quotes. Instead of

    " WHERE (((Year([InvoiceDate])) = " & CnstYear & ") And ((orders.CustomerID) = StrOffice)) ORDER BY products.grade"

    use

    " WHERE (((Year([InvoiceDate])) = " & CnstYear & ") And ((orders.CustomerID) = " & StrOffice & ")) ORDER BY products.grade"

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •