+ Reply to Thread
Results 1 to 3 of 3

Run-time error '438' Object doesn't support this property or method

Hybrid View

  1. #1
    Registered User
    Join Date
    05-23-2011
    Location
    Lincoln, NE
    MS-Off Ver
    Excel 2007
    Posts
    30

    Run-time error '438' Object doesn't support this property or method

    I am having all sorts of problems with a userform that I created. The current problem that I am having is that I am getting a run-time error 438 message when I click the "Log" command button. This button is supposed to 1) validate the entries on the userform; 2) write the data from the userform to a spreadsheet log; and 3) save the log.

    The error seems to be occurring in step 2 of the above. Attached is the workbook and below is the code for the command button.

    Private Sub cmdLog_Click()
    Dim rowcount As Long
    Dim ctl As Control
    
    'Populate Ending time
        Me.txtEnd = Format(Now, "HH:MM:SS")
    'Calculate elapsed time
        Me.txtElapsed = Format((TimeValue(txtStart.Value) - TimeValue(txtEnd.Value)), "HH:MM:SS")
        
    'Validate entries
        If Me.cboPrintedBy.Value = "" Then
            MsgBox "Please select the name of the person doing the fingerprinting from the drop-down list.", vbExclamation, "Log Entry"
            Me.cboPrintedBy.SetFocus
            Exit Sub
        End If
        If Me.txtName.Value = "" Then
            MsgBox "Please record the name of the applicant being fingerprinted.", vbExclamation, "Log Entry"
            Me.txtName.SetFocus
            Exit Sub
        End If
        If Me.cboReason.Value = "" Then
            MsgBox "Please select the reason for the fingerprints from the drop-down list.", vbExclamation, "Log Entry"
            Me.cboReason.SetFocus
            Exit Sub
        End If
        If Me.optApp.Value = "false" And Me.optCID.Value = "False" Then
            MsgBox "Please indicate if the print cards will be processed by CID or taken by the applicant.", vbExclamation, "Log Entry"
            Exit Sub
        End If
        
    'Record data to spreadsheet
    rowcount = Worksheets("2011 Log").Range("a1").CurrentRegion.Rows.Count
        With Worksheets("2011 Log")
        .Offset(rowcount, 0).Value = Me.txtDate.Value
        .Offset(rowcount, 1).Value = Me.txtStart.Value
        .Offset(rowcount, 2).Value = Me.txtName.Value
        .Offset(rowcount, 3).Value = Me.cboReason.Value
        .Offset(rowcount, 4).Value = Me.cboPrintedBy.Value
        .Offset(rowcount, 5).Value = Me.txtEnd.Value
        If Me.optApp.Value = True Then
            .Offset(rowcount, 6).Value = "Go"
        ElseIf Me.optCID.Value = True Then
            .Offset(rowcount, 6).Value = "Stay"
        End If
        .Offset(rowcount, 7).Value = Me.txtElapsed.Value
    End With
    'Save the log
        ActiveWorkbook.Save
           
    End Sub
    Attached Files Attached Files
    Last edited by Lothar69; 07-26-2011 at 03:31 PM.

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259

    Re: Run-time error '438' Object doesn't support this property or method

    Hello Lothar69,

    You need to specify a cell from which to offset. See text in bold below.
    Private Sub cmdLog_Click()
    Dim rowcount As Long
    Dim ctl As Control
    
    'Populate Ending time
        Me.txtEnd = Format(Now, "HH:MM:SS")
    'Calculate elapsed time
        Me.txtElapsed = Format((TimeValue(txtStart.Value) - TimeValue(txtEnd.Value)), "HH:MM:SS")
        
    'Validate entries
        If Me.cboPrintedBy.Value = "" Then
            MsgBox "Please select the name of the person doing the fingerprinting from the drop-down list.", vbExclamation, "Log Entry"
            Me.cboPrintedBy.SetFocus
            Exit Sub
        End If
        If Me.txtName.Value = "" Then
            MsgBox "Please record the name of the applicant being fingerprinted.", vbExclamation, "Log Entry"
            Me.txtName.SetFocus
            Exit Sub
        End If
        If Me.cboReason.Value = "" Then
            MsgBox "Please select the reason for the fingerprints from the drop-down list.", vbExclamation, "Log Entry"
            Me.cboReason.SetFocus
            Exit Sub
        End If
        If Me.optApp.Value = "false" And Me.optCID.Value = "False" Then
            MsgBox "Please indicate if the print cards will be processed by CID or taken by the applicant.", vbExclamation, "Log Entry"
            Exit Sub
        End If
        
    'Record data to spreadsheet
    rowcount = Worksheets("2011 Log").Range("a1").CurrentRegion.Rows.Count
        With Worksheets("2011 Log").Range("A1")
        .Offset(rowcount, 0).Value = Me.txtDate.Value
        .Offset(rowcount, 1).Value = Me.txtStart.Value
        .Offset(rowcount, 2).Value = Me.txtName.Value
        .Offset(rowcount, 3).Value = Me.cboReason.Value
        .Offset(rowcount, 4).Value = Me.cboPrintedBy.Value
        .Offset(rowcount, 5).Value = Me.txtEnd.Value
        If Me.optApp.Value = True Then
            .Offset(rowcount, 6).Value = "Go"
        ElseIf Me.optCID.Value = True Then
            .Offset(rowcount, 6).Value = "Stay"
        End If
        .Offset(rowcount, 7).Value = Me.txtElapsed.Value
    End With
    'Save the log
        ActiveWorkbook.Save
           
    End Sub
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  3. #3
    Registered User
    Join Date
    05-23-2011
    Location
    Lincoln, NE
    MS-Off Ver
    Excel 2007
    Posts
    30

    Re: Run-time error '438' Object doesn't support this property or method

    Thanks Leith. That resolved my issue. I'll post a new thread on my next issue.

+ 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