+ Reply to Thread
Results 1 to 2 of 2

First Time VBA and getting Compile Error

  1. #1
    Forum Contributor
    Join Date
    02-13-2012
    Location
    UK
    MS-Off Ver
    Excel 2013
    Posts
    105

    First Time VBA and getting Compile Error

    Apologies guys but this is my first attempt at VBA and I cannot fix this error. I keep getting error - Compile Error - Method or Data Member Not Found. Can anyone help me out please?

    Private Sub cboProblemCategory_DropButtonClick()
    Me.cboProblemCategory.AddItem "Tooling"
    Me.cboProblemCategory.AddItem "Design"
    Me.cboProblemCategory.AddItem "Operator"
    Me.cboProblemCategory.AddItem "Documentation"
    Me.cboProblemCategory.AddItem "Missing Part"
    Me.cboProblemCategory.AddItem "Damaged Part"
    End Sub

    Private Sub cboSeverity_DropButtonClick()
    'Populate control.
    Me.cboSeverity.AddItem "High"
    Me.cboSeverity.AddItem "Medium"
    Me.cboSeverity.AddItem "Low"
    End Sub

    Private Sub cmdAdd_Click()
    'Copy input values to sheet.
    Dim lRow As Long
    Dim ws As Worksheet
    Set ws = Worksheets("NCR Form")
    1 Row = ws.Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).Row
    With ws
    .Cells(lRow, 1).Value = Me.txtdate.Value
    .Cells(lRow, 2).Value = Me.txtJobNumber.Value
    .Cells(lRow, 3).Value = Me.txtRaisedBy.Value
    .Cells(lRow, 4).Value = Me.txtProjectManager.Value
    .Cells(lRow, 5).Value = Me.cboSeverity.Value
    .Cells(lRow, 6).Value = Me.txtCause.Value
    .Cells(lRow, 7).Value = Me.txtCorrectiveAction.Value
    .Cells(lRow, 8).Value = Me.txtPreventativeAction.Value
    .Cells(lRow, 9).Value = Me.txtTimeTakenMins.Value
    .Cells(lRow, 10).Value = Me.txtMaterialCost.Value
    .Cells(lRow, 11).Value = Me.txtTimeToReInspectMins.Value
    .Cells(lRow, 12).Value = Me.cboProblemCategory.Value
    .Cells(lRow, 13).Value = Me.txtTotalTime.Value
    .Cells(lRow, 14).Value = Me.obClosed.Value
    End With
    'Clear input controls.
    Me.txtdate.Value = ""
    Me.txtJobNumber.Value = ""
    Me.txtRaisedBy.Value = ""
    Me.txtProjectManager.Value = ""
    Me.cboSeverity.Value = ""
    Me.txtCause.Value = ""
    Me.txtCorrectiveAction.Value = ""
    Me.txtPreventativeAction.Value = ""
    Me.txtTimeTakenMins.Value = ""
    Me.txtMaterialCost.Value = ""
    Me.txtTimeToReInspectMins.Value = ""
    Me.cboProblemCategory.Value = ""
    Me.txtTotalTime.Value = ""
    Me.obClosed.Value = ""
    End Sub
    Private Sub cmdClose_Click()
    'Close UserForm.
    Unload Me
    End Sub

    I also don't know how to add the Field Names to the Userform - can anyone also guide me with this?

    Command Button 1 is Save

    Thanks Guys.
    Attached Files Attached Files

  2. #2
    Forum Expert
    Join Date
    02-14-2009
    Location
    .
    MS-Off Ver
    ................
    Posts
    2,840

    Re: First Time VBA and getting Compile Error

    You have no control named txtDate - look closely at the properties of the textbox and that's not the only control with that type of error.

    You should use the DEBUG/COMPILE menu options to find errors like this. Posting on a forum is a waste of your time for something so simple.

    But for something completely different, you should check this carefully
    Please Login or Register  to view this content.
    Make sure lRow has the value you'd expect it to have before that line executes.
    Last edited by cytop; 09-27-2016 at 07:47 AM. Reason: typo

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Getting compile error 13 time mismatch
    By mso3 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-31-2014, 12:38 AM
  2. i am getting an compile time error called variable not defined please help me out
    By baig123 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 04-24-2014, 08:23 AM
  3. [SOLVED] Compile Error in Hidden Module and Compile Error: Can't find project or library
    By Taislin in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 08-10-2013, 07:03 PM
  4. [SOLVED] VBA, Excel run-time error '381' and now a Compile Error
    By eemiller1997 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 12-20-2012, 12:46 PM
  5. Compile error with format date and time
    By aman1234 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 04-28-2009, 08:46 AM
  6. VBAProject name compile error, not defined at compile time
    By Matthew Dodds in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 12-13-2005, 03:20 PM
  7. [SOLVED] Run Time Error 9 Compile Error
    By ExcelMonkey in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 10-05-2005, 01:05 PM

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