Active Member
September 12, 2018
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!
Power Query
Power Pivot
Xtreme Pivot Tables
Excel for Decision Making
Excel for Finance
Excel Analysis Toolpak
Power BI
Excel
Word
Outlook
Excel Expert
Excel Customer Service
PowerPoint
November 8, 2013
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.
1 Guest(s)