• Event procedure for control on dynamic form

    Home » Forums » AskWoody support » Productivity software by function » MS Access and database help » Event procedure for control on dynamic form

    Author
    Topic
    #472167

    Hi,

    I’m creating a database that will allow users to select various options and then select a template they wish to generate in Word. Depending on the template they choose, I want to display additional options for them to fill values in to. These options will change depending on the template they choose.

    I’m trying to create a dynamic form which will allow the user to select what options they chose from the main screen, but also present the additional options I want them to fill out on a ‘pop-up’ (dynamic) form. Based on the options they chose on the main screen along with the additional options they fill out on the pop-up form, this will allow them to generate their template.

    I don’t want to save the pop-form I present to the user. I just want to use this as a way for the user to review what they previously filled in and also add additional data before they generate the template.

    I can create the form ok and create labels etc which shows the options they’ve chosen. I can also create text boxes etc for them to fill out additional data. I’m also creating a button which the user will click, at which point I’m then trying to call another routine which will actually generate the letter in Word. Basically I need to set the ‘On Click’ event of this button to call the routine. I’ve tried just setting the ‘On Click’ property of the button to call the routine directly – Eg, =GenerateLetters(), but I receive an error when I do this. I think I need to set an ‘event procedure’ on the button once it’s created, but not sure if I’m able to do this since the form itself isn’t saved. Is this possible? Is there another/better way to do this?

    Cheers,

    Viewing 7 reply threads
    Author
    Replies
    • #1248584

      I think a better way for you to approach this would be to examine your reasoning for not creating a persistant form and showing, hiding and populating controls etc as needed. Creating a form “On the fly” in design view seems to me to be frought with potential disaster.

      Is there a reason you are not creating a persistant form?

      Bob Oxford

    • #1248896

      Hi bob,

      I thought about this, but one of the reasons I thought about not doing this was that depending on where teh controls were created on the form in the first place, they would appear in different spots as others were hidden or unhidden. (Eg, one control might appear at the top of the form while another might in the bottom right.

      Is there a way around this?

      Cheers,
      Jason

    • #1248898

      Sure…

      One way is to set up a Tab Control with a different page for each situation. Put the controls in places that you want them and then just choose the desired page of the tab depending on the scenario.

      Another way is to move the controls around on the form by setting the Left and Top Properties as needed.

      Also, Controls can overlay each other in design view and you can just set the Visible property of each control depending on the situation. Lots of ways to work this out.

      Hope that helps.

      Bob Oxford

      • #1248910

        One way is to set up a Tab Control with a different page for each situation. Put the controls in places that you want them and then just choose the desired page of the tab depending on the scenario.

        I agree with the idea of just showing/hiding the controls according to the situation, but I believe (from previous threads) that there actually 100 situations. A Tab control with 100 pages would be a nightmare to manage.

        Could the 100 (or so) situations be grouped into Categories, so that users first choose a Category, then make a specific choice from within that Category.

    • #1248920

      Another way is to move the controls around on the form by setting the Left and Top Properties as needed.

      Hi Bob,

      Am I able to do this ‘dynamically’? By that I mean, without putting the form into design view, moving the fields around and then redisplaying the form?

      Cheers,
      Jason

    • #1248921

      Yes you can move controls via code without switching to Design view.

    • #1248924

      Yes you can move controls via code without switching to Design view.

      Hi John,

      Are you able to point me in the right direction for this as far as code goes? I’m actually thinking of using this for another question I just posted about whether to use 2 tables for ‘individuals’ and ‘corporations’. For example, if a user wishes to create a new ‘client’, I currently have a drop down box which lets them select ‘individual’ or ‘client’. Depending on what they choose, I want to unhide and hide and also move controls around dynamically.

      cheers,
      Jason

    • #1248926

      The attachment has some code that moves controls around and hides/shows them in the after update event.
      The Unit used for the Left and Top Properties is the TWIP. There are 567 twips in a cm and (Ithink) 1440 in an inch, so you need big numbers.

    • #1249065

      Thanks for all the help guys, much appreciated!

    Viewing 7 reply threads
    Reply To: Event procedure for control on dynamic form

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: