Hi all, TFiske...again,
First of all, I want to thank to AlphaFrog, mehmetcik, Arkadi, bakerman2, xladept, and Winon for their help in getting me this far with this project.
Here's the new problem:
I have a Multi-Tab UserForm in which the user will check boxes if a given chemical is of a given type. Then the .Caption parameter for each box checked is concatenated with the following code and stored in a cell in column 4 of the "Chemical's" table:
Dim chkChem As Control
Dim ChemType As String
Dim delim As String
delim = ", "
For Each chkChem In Me.Frm_ChemType.Controls
If TypeOf chkChem Is MSForms.CheckBox Then
If (chkChem.Value = True) Then
ChemType = ChemType & delim & chkChem.Caption
End If
End If
Next
Now, on the Edit Chemical Record tab of the userform, I need to set these checkboxes to True if their caption is found in the string generated by the code above when the user selects a stored Chemical Record from a ComboBox. I've tried a few approaches but haven't gotten anywhere.
Most recently I've tried a public function with InStr:
Private Sub ctrl1_Change()
Dim wb As Workbook
Dim ws As Worksheet
Set wb = ThisWorkbook
Set ws = wb.Worksheets("Chemicals")
Dim rowIndex As Long
Dim c As Long
rowIndex = Application.Match(Me.ctrl1.Value, ws.Columns(1), 0)
For c = 1 To 6
Public Function ChemCheck(ChemBaseStr As String, ChemTypeStr As String) As Boolean
ChemBaseStr = ws.Cells(rowIndex, 4)
ChemTypeStr = Me.Controls("chk" & c).Caption
ChemCheck = InStr(ChemBaseStr, ChemTypeStr)
If ChemCheck = True Then
Me.Controls("chk" & c).Value = True
End If
End Function
Next
This latest method gives me an "Expected End Sub" error. The other method's I've tried don't seem to do anything. I've attached a copy of the project. The UserForm in question is UsrFrm_ChemicalMaintenance. Thanks again!
Bookmarks