+ Reply to Thread
Results 1 to 4 of 4

Form not displaying cell data on load.

Hybrid View

  1. #1
    Registered User
    Join Date
    01-07-2010
    Location
    Oregon
    MS-Off Ver
    Excel 2007, 2010 - maintain backwards compatibility to 2003 when possible
    Posts
    17

    Exclamation Form not displaying cell data on load.

    I've written a form that enters data into cells via text boxes, and (I think) the code to load the data from those cells back into the form whenever it's loaded. However, when I load the form, all of the text boxes are blank.

    Here's the code I use to enter data into a cell (one of many)

    Private Sub Term1_Change()
        m_wb.Worksheets("Leasing Data").Range("B21").Value = Term1.Text
    End Sub


    Here's the code I would expect to load the cell data back into the form when it's launched.

    Private Sub UserForm_Activate()
        On Error Resume Next
        If m_fHidden = True Then
            m_fHidden = False
            Term1.Value = m_wb.Worksheets("Leasing Data").Range("B21").Value
        End If
    End Sub

    I'm sure this is a novice fix, I have basically just copied and pasted code from another form that someone else built, so any help would be appreciated.
    Last edited by vaximily; 05-09-2011 at 06:17 PM.

  2. #2
    Forum Expert tigeravatar's Avatar
    Join Date
    03-25-2011
    Location
    Colorado, USA
    MS-Off Ver
    Excel 2003 - 2013
    Posts
    5,361

    Re: Form not displaying cell data on load.

    vaximily,

    Use the UserForm_Initialize event instead of UserForm_Activate activate.

    Hope this helps,
    ~tigeravatar

  3. #3
    Registered User
    Join Date
    01-07-2010
    Location
    Oregon
    MS-Off Ver
    Excel 2007, 2010 - maintain backwards compatibility to 2003 when possible
    Posts
    17

    Exclamation Re: Form not displaying cell data on load.

    Quote Originally Posted by tigeravatar View Post
    vaximily,

    Use the UserForm_Initialize event instead of UserForm_Activate activate.

    Hope this helps,
    ~tigeravatar
    No change. It did bring to mind the difference between loading / showing forms and such. In a nutshell, I have 2 forms (frmWizard and frmDefaults). frmWizard is displayed when the excel file is opened initially, and can be accessed again via command buttons from each worksheet.


    The code to launch frmWizard when the spreadsheet is opened is:
    Private Sub Workbook_Open()
        frmWizard.Show vbModal
    End Sub

    The command button code to access frmWizard is:
    Private Sub cmdShowWiz0_Click()
        frmWizard.Show    
    End Sub

    From there, there is a button on frmWizard to show frmDefaults, which has this code:
    Private Sub cmdDefaults_Click()
        frmDefaults.Show
    End Sub
    So, maybe that will help the troubleshooting process?
    Last edited by vaximily; 05-09-2011 at 05:16 PM.

  4. #4
    Registered User
    Join Date
    01-07-2010
    Location
    Oregon
    MS-Off Ver
    Excel 2007, 2010 - maintain backwards compatibility to 2003 when possible
    Posts
    17

    Re: Form not displaying cell data on load.

    Looking through this, I am having a hard time understand what the following code does. However, when I comment it out, the rest of it seems to work fine.

    If m_fHidden = True Then
            m_fHidden = False
    End If

+ 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