+ Reply to Thread
Results 1 to 9 of 9

Compile error Method or data member not found

Hybrid View

  1. #1
    Registered User
    Join Date
    01-12-2014
    Location
    Plano, Tx
    MS-Off Ver
    365
    Posts
    57

    Compile error Method or data member not found

    Excel 10
    I am getting this error, method or data member not found on a Userform Text box label. All the other text boxes seem to work fine. I checked the properties and it is spelled correctly. I'm sure it's in my code somewhere. Here is the line of code getting the error:
    ElseIf Label_Date.Value = "" Then

    Here is my full code:

     Private Sub CommandButton_Close_Click()
     Unload Me
     End Sub
     Private Sub Label_Contacted_Click()
     End Sub
     Private Sub OptionButton1_Click()
     End Sub
     Private Sub OptionButton2_Click()
     End Sub
     Private Sub OptionButton3_Click()
     End Sub
     Private Sub UserForm_Initialize() 'List of 35 stores on the "Stores" worksheet
     For i = 1 To 35
     ComboBox_Country.AddItem Sheets("Stores").Cells(i, 1)
     Next
     End Sub
     Private Sub OptionButton4_Click()
     End Sub
     Private Sub UserForm1_Initialize() 'List of Type of Complaints on the "Type" worksheet
     For i = 1 To 6
     ComboBox_Country1.AddItem Sheets("Type").Cells(i, 1)
     Next
     End Sub
     Private Sub CommandButton_Add_Click()
     'Setting Label color to black
     Label_Last_Name.ForeColor = RGB(0, 0, 0)
     Label_First_Name.ForeColor = RGB(0, 0, 0)
     Label_Address.ForeColor = RGB(0, 0, 0)
     Label_Place.ForeColor = RGB(0, 0, 0)
     Label_Country.ForeColor = RGB(0, 0, 0)
     Label_Date.ForeColor = RGB(0, 0, 0)
     Label_Country1.ForeColor = RGB(0, 0, 0)
     'Content controls
     If TextBox_Last_Name.Value = "" Then 'If no "name" provided ...
     Label_Last_Name.ForeColor = RGB(255, 0, 0) 'Set Label "name" color to red
     ElseIf TextBox_First_Name.Value = "" Then
     Label_First_Name.ForeColor = RGB(255, 0, 0)
     ElseIf TextBox_Address.Value = "" Then
     Label_Address.ForeColor = RGB(255, 0, 0)
     ElseIf TextBox_Place.Value = "" Then
     Label_Place.ForeColor = RGB(255, 0, 0)
     ElseIf ComboBox_Country.Value = "" Then
     Label_Country.ForeColor = RGB(255, 0, 0)
     ElseIf Label_Date.Value = "" Then
     Label_Date.ForeColor = RGB(255, 0, 0)
     ElseIf ComboBox_Country1.Value = "" Then
     Label_Country1.ForeColor = RGB(255, 0, 0)
     Else
    
     'If the form is complete, the values will be inserted onto the worksheet
     Dim row_number As Integer, contacted As String
    
     'Choice of salutation
     For Each contacted_button In Frame_Salutation.Controls
     If contacted_button.Value Then
     contacted = contacted_button.Caption
     End If
     Next
     'row_number = row number of the last non-empty cell in column +1
     row_number = Range("A65536").End(xlUp).Row + 1
     'Inserting values onto the worksheet
     Cells(row_number, 1) = contacted
     Cells(row_number, 2) = TextBox_Last_Name.Value
     Cells(row_number, 3) = TextBox_First_Name.Value
     Cells(row_number, 4) = TextBox_Address.Value
     Cells(row_number, 5) = TextBox_Place.Value
     Cells(row_number, 6) = ComboBox_Country.Value
     Cells(row_number, 7) = TextBox_Date.Value
     Cells(row_number, 8) = ComboBox_Country1.Value
     'After insert, we replace the initial values
     OptionButton1.Value = True
     TextBox_Last_Name.Value = ""
     TextBox_First_Name.Value = ""
     TextBox_Address.Value = ""
     TextBox_Place.Value = ""
     ComboBox_Country.ListIndex = -1
     TextBox_Date.Value = ""
     ComboBox_Country1.ListIndex = -1
     End If
     End Sub
    Last edited by 6StringJazzer; 08-29-2016 at 03:40 PM.

  2. #2
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS 365 Family 64-bit 2502
    Posts
    26,910

    Re: Compile error Method or data member not found

    This error is almost certainly because your UserForm does not have a control called Label_Date. Can you confirm that this control exists? If so, can you attach your file so we can investigate further?
    Jeff
    | | |會 |會 |會 |會 | |:| | |會 |會
    Read the rules
    Use code tags to [code]enclose your code![/code]

  3. #3
    Registered User
    Join Date
    01-12-2014
    Location
    Plano, Tx
    MS-Off Ver
    365
    Posts
    57

    Re: Compile error Method or data member not found

    Ok, thanks Jeff. I will take a look at the UserForm. Also, I don't want to attach the file incorrectly. Can you send quick instructions on how, Thanks.

  4. #4
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS 365 Family 64-bit 2502
    Posts
    26,910

    Re: Compile error Method or data member not found

    Under the text box where you type your reply click the Go Advanced button. On the next screen scroll down and click on Manage Attachments, which will show a pop-up window to Select and Upload a file. Then close the window.

  5. #5
    Registered User
    Join Date
    01-12-2014
    Location
    Plano, Tx
    MS-Off Ver
    365
    Posts
    57

    Re: Compile error Method or data member not found

    Ok, I figured out my error on the text box label issue, but now I'm having an issue with the 2nd combo box. First combo Box works fine, but no drop down list is showing up on the 2nd combo box. I am attaching the sheet. You can go through a dummy trial of adding a complaint and see how it happens.
    Here is the code:
    Private Sub UserForm_Initialize() 'List of 35 stores on the "Stores" worksheet
     For i = 1 To 35
     ComboBox_Country.AddItem Sheets("Stores").Cells(i, 1)
     Next
     End Sub
     Private Sub OptionButton4_Click()
     End Sub
     Private Sub UserForm1_Initialize() 'List of Type of Complaints on the "Type" worksheet
     For i = 1 To 6
     ComboBox_Country1.AddItem Sheets("Type").Cells(i, 1)
     Next
     End Sub
    Attached Files Attached Files
    Last edited by 6StringJazzer; 08-30-2016 at 08:43 AM. Reason: Adding missing bracket to fix code tag

  6. #6
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS 365 Family 64-bit 2502
    Posts
    26,910

    Re: Compile error Method or data member not found

    You have UserForm_Initialize declared twice so the form doesn't come up at all. I think your problem will be solved if you combine the code from those two subs into a single sub.

    It's also confusing that you have a field labelled "Complaint Type" but the corresponding combobox is called ComboBox_Country1. That doesn't cause a bug but it makes the code very confusing.

  7. #7
    Registered User
    Join Date
    01-12-2014
    Location
    Plano, Tx
    MS-Off Ver
    365
    Posts
    57

    Re: Compile error Method or data member not found

    Thanks for all you have done. I figured it out. Can't have both declared twice. I put the code under one and it works perfectly.
    Again, thank you very much!!

  8. #8
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,644

    Re: Compile error Method or data member not found

    Your post does not comply with Rule 8 of our Forum RULES. Do not crosspost your question on multiple forums without including links here to the other threads on other forums.

    Cross-posting is when you post the same question in other forums on the web. The last thing you want to do is waste people's time working on an issue you have already resolved elsewhere. We prefer that you not cross-post at all, but if you do (and it's unlikely to go unnoticed), you MUST provide a link (copy the url from the address bar in your browser) to the cross-post.

    Expect cross-posted questions without a link to be closed and a message will be posted by the moderator explaining why. We are here to help so help us to help you!

    Read this to understand why we ask you to do this, and then please edit your first post to include links to any and all cross-posts in any other forums (not just this site).
    If posting code please use code tags, see here.

  9. #9
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS 365 Family 64-bit 2502
    Posts
    26,910

    Re: Compile error Method or data member not found

    kwesmc1, MrExcel has the same rule. Please update both forum threads to show the cross-post.

+ 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] Compile error: Method or data member not Found
    By jasond1992 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-25-2015, 02:29 AM
  2. [SOLVED] Compile error: Method or data member not found
    By aliciaward1001 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 10-26-2015, 04:11 PM
  3. Compile error:Method or data member not found
    By vshukla in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-16-2015, 11:44 AM
  4. Compile error method or data member not found
    By sureshpunna in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 08-14-2014, 09:00 AM
  5. Compile Error Method or data member not found
    By ixelister in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 02-23-2014, 03:39 PM
  6. [SOLVED] Compile error: Method or data member not found.
    By ndtsteve in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 05-10-2012, 11:31 AM
  7. [SOLVED] Compile Error Method or data member not found
    By ExcelMonkey in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-04-2005, 06: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