none
Controls not formatted when creating another instance of form RRS feed

  • Question

  • I use a simple method to create another instance of a form. But the buttons do not hold their formatting.

    Private Sub btnOpenAnotherInstance_Click()
    Dim newForm As New Form_frmVenueDisplayAdManager
    newForm.visible = True
    End Sub

    Wednesday, February 10, 2016 5:15 PM

Answers

  • I've found a solution if anyone cares. Don't know if it is the best.

    Private Sub btnOpenAnotherInstance_Click()
    Dim newForm As New Form_frmVenueDisplayAdManager
    newForm.btnAddNewAd.UseTheme = True
    newForm.btnEditAd.UseTheme = True
    newForm.btnOpenAnotherInstance.UseTheme = True
    newForm.visible = True
    End Sub


    Other format properties also aren't set correctly in new instances which have to be changed besides UseTheme too
    Thursday, February 11, 2016 5:18 PM

All replies

  • hmmm not sure the concept is viable.  If you know the user behavior is going to be limited to 2 screens - you could copy the form object with a variant name ...and then open that......  
    Wednesday, February 10, 2016 10:12 PM
  • I'm not sure what your saying. I have no problem opening multiple instances, or even regulating the number of those instances. The user can open 100 if needed, and that is acceptable. My question should have been, why aren't the Controls on these instances formatted as the Controls on the original Form? The blue buttons are the original Form. That form has a button which executes the proc I posted above. Those additional instances have grey CommandButton controls. I just don't understand why they aren't formatted as the original, and is there an aproach I should be taking that would resolve that?
    Wednesday, February 10, 2016 10:48 PM
  • I've found a solution if anyone cares. Don't know if it is the best.

    Private Sub btnOpenAnotherInstance_Click()
    Dim newForm As New Form_frmVenueDisplayAdManager
    newForm.btnAddNewAd.UseTheme = True
    newForm.btnEditAd.UseTheme = True
    newForm.btnOpenAnotherInstance.UseTheme = True
    newForm.visible = True
    End Sub


    Other format properties also aren't set correctly in new instances which have to be changed besides UseTheme too
    Thursday, February 11, 2016 5:18 PM
  • Hi. Thanks for sharing the solution. But perhaps, if you need to instantiate multiple copies of a specific form, you might just consider not to use a theme for it to reduce the amount of work you have to do. Otherwise, I hope someone comes up with a simpler solution. Just my 2 cents...
    Thursday, February 11, 2016 5:31 PM
  • Hi HTHP,

    Based on my test with Access 2013, it works fine. What’s the version of your Access?

    Steps:

    1. Create a blank form with some buttons and text boxes
    2. Add the click event to a button with the code:
    Dim ff As Form
    Private Sub Command4_Click()
    
    Set ff = New Form_FormWithFormat
    ff.Visible = True
    End Sub
    

    1. Open that form and click button to create another instance of the form

    Please provide the detail steps you did.

    Regards

    Starain


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Friday, February 12, 2016 5:35 AM
    Moderator
  • I'm having the exact same issue and it's driving me crazy!  I'm using Access 2016.

    The workaround ALMOST works for me; however, when i re-apply the theme to my tab control...

    Form.ctl_Tabs.UseTheme = True

    Tab page images and style applies, but tab captions will not show!

    I'm hoping someone has an idea on this.

    Tuesday, June 7, 2016 5:18 AM
  • On further testing, the workaround doesn't work.  When I move a "partially corrected" form around the screen, it leaves all sorts of artifacts behind.  I tried disabling the graphics acceleration in the Access options, but that didn't make a difference.
    Tuesday, June 7, 2016 5:26 AM