Results 1 to 4 of 4
  1. #1
    Join Date
    Jul 2003
    Location
    Canberra, ACT Australia
    Posts
    53

    Unanswered: changing a control attribute when 'calling' a form

    Guys

    I have 2 command buttons on a form, which call the same form. The buttons open the same form, which has 2 sub-forms, but one button sets one of the subforms to .enabled = false and .visible = false : this is all working as it should.

    My problem is attempting to set the input mask to different settings on the main called form according to the button pressed on the calling form.

    example:

    button1.....opens main form ........displays subform1 & subform2
    mainform field taxfilenumber has input mask "TFN "000\-000\-000;0;_

    works as required.

    however:
    button2...opens mainform.......displays subform1 & not subform2
    works as required, so far;
    but I need to set mainform field taxfilenumber input mask to "ABN "000\-000\000;0;_ (or some other change.

    have tried in code various optiions:
    forms!mainformname.controlname.[input mask] = "xxxx"

    after opening the mainform have tried me!mainformname.control.[input mask] = "xxx"
    controlname.[input mask]="xxxx"

    How do I change the attribute, without having to have 2 forms?

    various errors:
    object doesn't support this method
    unable to find field forms!


    any help appreciated.

  2. #2
    Join Date
    Nov 2003
    Posts
    1,487
    In the On Click event of button 1 enter the following code line:

    Me.taxfilenumber.InputMask = Chr$(34) & "TFN " & Chr$(34) & "000\-000\-000;0;_"


    In the On Click event of button 2 enter the following code line:

    Me.taxfilenumber.InputMask = Chr$(34) & "ABN " & Chr$(34) & "000\-000\-000;0;_"


    Where: taxfilenumber is the textbox control name on the main form where the two buttons reside.

    Last edited by CyberLynx; 04-19-04 at 02:32.

  3. #3
    Join Date
    Jul 2003
    Location
    Canberra, ACT Australia
    Posts
    53
    many thanks. I ended up with a similar format with:

    with forms!formname!taxfilenumber
    .inputmask = "\ABN "&"000\-000\-000;0;_"
    end with

    I set up the input mask for the TFN in the initial table, so I only had to call the one format ie as above. Perhaps not as elegant as your solution.

    As an additional question, which do you consider more acceptable (commercially); the ommission of an inputmask in the table and then setting up two inputmasks via code as you have replied, or the setting up of an input mask in the table and then calling one change via code. I know there will be arguments for both, and consistency, preferences and standards arguments could ensue, but I was wondering what you had seen the most.

    cheers and thanks

  4. #4
    Join Date
    Nov 2003
    Posts
    1,487
    My answer would truely be irrelevant since it could change from one database to another. However, whichever method you choose should be the method that allows for the most flexability.


Posting Permissions

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