Results 1 to 5 of 5
  1. #1
    Silver Lounger
    Join Date
    Jun 2002
    Location
    Cheadle, Staffordshire
    Posts
    2,177
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Can a Const be changed (Access 2k)

    Can a Const be changed ?

    The following declaration needs to be changed later in my application to a variety of SQL statements.

    Const cUnitRS As String = "SELECT qryStaff.Active, * FROM qryStaff WHERE (((qryStaff.Active) = True)) ORDER BY qryStaff.Unit;"

    Can this be done ?

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

    Re: Can a Const be changed (Access 2k)

    Hi Dave,

    No, you'll have to declare cUnitRS as a variable:

    Dim cUnitRS As String
    cUnitRS = "SELECT qryStaff.Active, * FROM qryStaff WHERE (((qryStaff.Active) = True)) ORDER BY qryStaff.Unit;"

    You can then change it later on, whenever needed.

    BTW, you don't need qryStaff.Active in the SELECT part, you can change it to

    cUnitRS = "SELECT * FROM qryStaff WHERE qryStaff.Active = True ORDER BY qryStaff.Unit;"

  3. #3
    Silver Lounger
    Join Date
    Jun 2002
    Location
    Cheadle, Staffordshire
    Posts
    2,177
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Can a Const be changed (Access 2k)

    Hello Hans

    I had already done so giving the following error :

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

    Re: Can a Const be changed (Access 2k)

    Dave,

    You cannot assign a value to a variable in the declaration section of a module, you must do so inside a procedure or function. A good place for it would be the On Open or On Load event procedure of the form. The declaration Dim cUnitRS As String must remain where it is now.

  5. #5
    Silver Lounger
    Join Date
    Jun 2002
    Location
    Cheadle, Staffordshire
    Posts
    2,177
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Can a Const be changed (Access 2k)

    Aaaahh, common sense prevails !!, I should have known.

    Thanks Hans.

    I have a few changes to make to my holiday planner, I may be back. !!

Posting Permissions

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