I'm trying to capture if any changes are made to a UserForms selections.
I initially load all the data from the database when the first user form is initialized, see code below
Private Sub Userform_Initialize()
Dim Sourcewb As Workbook
Dim myRng As Range
With Me.cbxPlanning
.ColumnCount = 2
.ColumnWidths = "12;0" 'hide the second column
.Clear
Set Sourcewb = Workbooks.Open("Data Log.xlsx", False, True)
With Sourcewb.Worksheets(1)
Set myRng = .Range("A2:BV" & .Cells(.Rows.Count, "A").End(xlUp).Row)
End With
.List = myRng.Value
Sourcewb.Close False
End With
End Sub
Once I have selected the corresponing record from the combobox , in this case Planning Number, then select the command button which runs the code below
Private Sub CommandButton1_Click()
Dim myVar As Variant 'String/Long/double???
Dim myVar1 As String
With Me.cbxPlanning
If .ListIndex > -1 Then
myVar = .List(.ListIndex, 1) '<-- second column!
MsgBox myVar 'for testing only
myVar1 = .List(.ListIndex, 0)
Select Case myVar
Case Is = "Standard Process"
frmProcessEngineeringTemp.Show
End Select
End If
End With
End Sub
Now the user form frmProcessEngineeringTemp is opened, it now populates all the comboboxes, textboxes and option buttons in this form based on the planning number choosen from initial user form
Private Sub Userform_Initialize()
Dim myVar(1 To 40) As Variant
With frmLoadExistingPlanning.cbxPlanning
myVar1 = .List(.ListIndex, 0) 'Planning Number
myVar2 = .List(.ListIndex, 1) 'Product type
.
.
.
myVar40 = .List(.ListIndex, 51) 'Revision
End With
Once the user has finished with the user form the information from the form is passed to a worksheet via a command button. If changes to the user form selections were made i need to capture what has changed (if anything), from what was initially loaded into the second user form (frmProcessEngineeringTemp).
I have seen numerous posts from various sites that discuss Change and Exit events from a Class module and many instances where each combobox, textbox and option button is hard coded to capture changes.
Being that I have captured my initial inputs from the database thru the myVar 1 thru 40, can this be put into a string array and the current inputs/selections in the frmProcessEngineeringTemp put into a second array then compare 1 to another looking for difference, then output the differences to a worksheet for tracking purposes. At the same time if changes were indeed made i would increment the Revison record by 1.
I'm really not sure how to proceed, I'll be honest this is a real challange, well beyond my meager VBA skill sets, any suggestions would be greatly appreciated
I hope i have provided sufficient information to understand what i'm looking at
Thanks
Bookmarks