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)
' 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
.ListRows(Worksheets("Tables").ListObjects("Project").ListRows.Count).Range.Cells(1, 1) = Ctrl.Value
Ctrl.RowSource = "Project"
Any help will be appreciated! Thanks!
November 8, 2013
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.