+ Reply to Thread
Results 1 to 4 of 4

User form error when opened

  1. #1
    Registered User
    Join Date
    07-05-2005
    Posts
    11

    Question User form error when opened

    I am trying to develop a user form, named frmPAFD, in Excel 2000. I try to write a macro to open the form. It is simple, all I put is:

    frmPAFD.Show

    I have this in its own macro. However when I try to run it i get the error:
    "Object required" The only way I could get it to open was in its initialize event. There I input:

    frmPAFD.show

    It has also worked with:
    Load frmPAFD
    frmPAFD.Show

    But when I try to close it using a button I programed i get the same error and it jumps to the same line of code in my Macro. The only way I can view the form is if I do the frmPAFD.Show in the event mentioned earlier. I have consulted help pages both in excel and on Microsoft.com as well as other websites. They all say to view the form just type:

    frmPAFD.Show 'In its own Macro.

    Am I missing something like a reference or am I doing something wrong? Please let me know, and thanks for your help.

    theguz

  2. #2
    Jim Thomlinson
    Guest

    RE: User form error when opened

    A couple of question. Does your code compile? (Debug -> Compile) Also when
    the error occurs what line of code is it stopping on. Finally can you post
    your initialize, load, deactivate and terminate code for us to look at.
    --
    HTH...

    Jim Thomlinson


    "theguz" wrote:

    >
    > I am trying to develop a user form, named frmPAFD, in Excel 2000. I try
    > to write a macro to open the form. It is simple, all I put is:
    >
    > frmPAFD.Show
    >
    > I have this in its own macro. However when I try to run it i get the
    > error:
    > "Object required" The only way I could get it to open was in its
    > initialize event. There I input:
    >
    > frmPAFD.show
    >
    > It has also worked with:
    > Load frmPAFD
    > frmPAFD.Show
    >
    > But when I try to close it using a button I programed i get the same
    > error and it jumps to the same line of code in my Macro. The only way
    > I can view the form is if I do the frmPAFD.Show in the event mentioned
    > earlier. I have consulted help pages both in excel and on
    > Microsoft.com as well as other websites. They all say to view the form
    > just type:
    >
    > frmPAFD.Show 'In its own Macro.
    >
    > Am I missing something like a reference or am I doing something wrong?
    > Please let me know, and thanks for your help.
    >
    > theguz
    >
    >
    > --
    > theguz
    > ------------------------------------------------------------------------
    > theguz's Profile: http://www.excelforum.com/member.php...o&userid=24918
    > View this thread: http://www.excelforum.com/showthread...hreadid=384565
    >
    >


  3. #3
    Registered User
    Join Date
    07-05-2005
    Posts
    11
    Yes the code does compile, I don't get the error untill I open it or close the form. Here is the macro that opens the form:

    Sub frmPAFD_Activate()
    'This macro opens the user form

    frmPAFD.Show 'Here is where error always occurs

    End Sub

    And here is the initialize event code:

    Private Sub UserForm_Initialize()
    'Initialize the form properties when opened


    frmPAFD.Show 'With out this line I can't even preview the form.
    optbutton1 = False
    optButton2 = False
    Accttxt.Value = ""
    P_Stxt.Value = ""
    titletxt.Value = ""

    'Variable for "for" loop
    Dim i As Integer

    i = 1

    'Loop for initalizing all those txt boxes with almost same name
    For i = 1 To 24
    TextBoxi.Value = ""
    Next i

    Accttxt.SetFocus

    End Sub

    I haven't added code to the load, deactivate and terminate events yet. I have been to frustrated to continue. Thanks you very much for the reply. Other forums haven't given me a response yet.
    theguz

  4. #4
    Forum Contributor
    Join Date
    05-04-2005
    Posts
    136
    i may be wrong but if i remember correctly, your code should be in the UserForm_Activate event not frmPADF_Activate. this should be in the code for that form so excel recognizes which form it's for.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1