I am setting up a userform to capture new client data. Each client is assigned a client ID (number) next to which the input data is saved in an excel sheet. A new userform with an estimate design summary is opened once the first userform is completed.
I want to save the assigned client ID number in die first userform to a textbox on the second userform, but a type mismatch error keeps popping up. On debugging it shows that the value assigned to the variable is not carried over to the textbox.
(The same code worked previously on these same userforms and still works on later userforms
Private Sub Continue1_Click()
'Determine empty row
Dim emptyRow As Long
Sheet5.Activate
emptyRow = WorksheetFunction.CountA(Range("B:B")) + 1
'Transfer userform data to spreadsheet
Cells(emptyRow, 2).Value = CName.Value
Cells(emptyRow, 3).Value = Business.Value
Cells(emptyRow, 4).Value = Region.Value
Cells(emptyRow, 5).Value = Email.Value
Cells(emptyRow, 6).Value = CNumber.Value
Cells(emptyRow, 7).Value = WSource.Value
Cells(emptyRow, 8).Value = Flow.Value
Cells(emptyRow, 9).Value = Pressure.Value
Cells(emptyRow, 10).Value = Irrigation.Value
'Load Design Estimation userform
DesignEst.Client_ID.Value = emptyRow - 1
Unload Me
DesignEst.Show
End Sub
If emptyRow
has a value of 5
this value has to be assigned to the Client_ID
textbox on the DesignEst
userform but currently it yields:
DesignEst.Client_ID.Value = ""
instead of:
DesignEst.Client_ID.Value = "5"
Yup I faced the same issues earlier. For some reason, the userform initialises with the design properties rather than what has been assigned in run time. Since the persistent data is already available in the corresponding cells, you could try to perform the Design Estimation userform assignments on the "Form_initialize" event. Hope that works.