Results 1 to 3 of 3
  1. #1
    4 Star Lounger
    Join Date
    Feb 2002
    Posts
    537
    Thanks
    0
    Thanked 0 Times in 0 Posts

    global code doesnt work (Access 2000)

    Global code doesnt work

    I have an option box called office with 10 options- 1,2,etc.

    After several attempts i still cannot make my code work. If i hard code city to be for example 2, then the corde works all right, and i get
    the results for the office number 2.
    However if i write city = Forms![FOrderInformation]![office] - 1, to obtain the global code, then mt code does not show the right
    figures,it shows on the results of office 1.

    Can somebody help me in my despair?




    Dim city As Long
    city = 2 my code works if i hard code city to be 2
    'city = Forms![FOrderInformation]![office] - 1 ' the code doesnt work and points only to office number 1


    Dim strBas As String
    Dim strOffice As String

    strbas = " SELECT customers.Customerid, customers.CompanyName, customers.afid " & _
    " FROM affiliates INNER JOIN customers ON affiliates.afid = customers.afid " & _
    " WHERE (((customers.afid) = " & city & "))"

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

    Re: global code doesnt work (Access 2000)

    (1) Open your form in design view. Double check the option values of each of the radio buttons in the "office" option group. Perhaps one of the values is not what you intended.

    (2) Temporarily insert a statement

    MsgBox Forms![FOrderInformation]![office]

    right above

    city = Forms![FOrderInformation]![office] - 1

    to inspect the value of [office] in runtime.

  3. #3
    Gold Lounger
    Join Date
    Jun 2001
    Location
    Crystal Beach, FL, Florida, USA
    Posts
    3,436
    Thanks
    1
    Thanked 34 Times in 34 Posts

    Re: global code doesnt work (Access 2000)

    Dim city As Long
    city = 2 my code works if i hard code city to be 2
    'city = Forms![FOrderInformation]![office] - 1 ' the code doesnt work and points only to office number 1


    Why do you have "-1" in the formula above? It seems to me that if you have selected choice #2 in Office, you are subtracting 1 from that, so you are getting city=1!
    Mark Liquorman
    See my website for Tips & Downloads and for my Liquorman Utilities.

Posting Permissions

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