Forum

Add Data to Combo B...
 
Notifications
Clear all

Add Data to Combo Box Drop Down List in Excel Form

2 Posts
2 Users
0 Reactions
109 Views
(@tborg51)
Posts: 5
Active Member
Topic starter
 

This project follows the article by Phil of the same name.  In my Excel Form I am trying to get the VBA to add a new entry in a table called "Project" which begins with a blank line.  When I add the new entry into the "Project" ComboBox on the form, it populates the worksheet but does not add the new entry to the Projecttable.  Below is my VBA, and the worksheet file is attached.

Function CheckForErrors() As Integer

   Dim Ctrl As MSForms.Control

   For Each Ctrl In WorkstreamForm.Controls

      Select Case TypeName(Ctrl)

         Case "ComboBox"
            ' If a new entry has been typed in
               If Ctrl.ListIndex = -1 Then

                  Ctrl.RowSource = ""

                 ' Add to relevant table : Project
                 If Ctrl.Name = "Project" Then

                     With Worksheets("Tables").ListObjects("Project")

                        .ListRows.Add
                        .ListRows(Worksheets("Tables").ListObjects("Project").ListRows.Count).Range.Cells(1, 1) = Ctrl.Value

                   End With

                   Ctrl.RowSource = "Project"

              End If

       End If

   End Select

End Function

 

Any help will be appreciated!  Thanks!

 
Posted : 23/07/2019 5:56 pm
(@catalinb)
Posts: 1937
Member Admin
 

Hi Tom,

In the ResetForm code, you refer to AssignedDate.Value, there is no control with that name in the form. There is a label, Label10, its caption is "Assigned Date"

You code should say: Label10.Caption = Date, if you want to pass a date in label text.

That should be corrected in the code that writes to sheet: .Cells(1, 8) = Label10.Caption

There is a missing reference in your project, go to Tools-References and uncheck that missing reference checkbox, those controls are not used in your project, will work without that reference.

Or, download the controls from microsoft.

 
Posted : 26/07/2019 11:28 am
Share: