Results 1 to 2 of 2
  1. #1
    2 Star Lounger
    Join Date
    Aug 2005
    Thanked 0 Times in 0 Posts

    module in the form (Access 2000)

    I define the record source in the OnOpen event for example
    Dim RecordSource1 As String
    RecordSource1 = " SELECT ....etc"

    However RecordSource1 is valid only for the OnOpen event of the form. And i want to use is also in other functions of the same form, but it is not recognized. Where and how shall i define this value so to be valid for all the functions in the form ?

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Thanked 31 Times in 31 Posts

    Re: module in the form (Access 2000)

    If you place the declaration

    Dim RecordSource1 As String

    in the On Open event procedure, the variable is local to that procedure, it will not be known outside the procedure. If you want to use it throughout the module, you must place the declaration at the top of the module, above all Subs and Functions. Since you only want to use it in the form module, you can declare it as private:

    Private RecordSource1 As String

    You must leave the line that assigns a value to RecordSource1 in the On Open event procedure.

Posting Permissions

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