I am trying to set the value of a text control when I show my userform. The value that I'm trying to set the control to comes from a variable that's on another user form. So for instance: I have two UserForms ... (UserForm_1) and (UserForm_2)
on UserForm_1, I cycle thru the rows and capture the row number then I set the value of [txtRow] which is a text control on UserForm_2 to the row number and then I show UserForm_2. The UserForm opens with the number 20 in the control named [txtRow]. That works just fine.
But when I try to initialize UserForm_2 it gives me problems. For instance, I have some variables on UserForm_2 that I need to initialize. One of the varialbles I'm trying to set to [txtRow].value which should be 20 that was passed from "myRow" on UserForm_1. But when I run the code it comes back with an error "Type mismatch". Here's my code:
on UserForm_1, I cycle thru the rows and capture the row number then I set the value of [txtRow] which is a text control on UserForm_2 to the row number and then I show UserForm_2. The UserForm opens with the number 20 in the control named [txtRow]. That works just fine.
Code:
Private Sub cmdUpdateDB_Click()
dim myRow as variant
lastrow = Cells(Rows.Count, "b").End(xlUp).Row
For I = 20 To lastrow
myRow = I
UserForm_2![txtRow].Value = myRow
UserForm_2.Show
Next
But when I try to initialize UserForm_2 it gives me problems. For instance, I have some variables on UserForm_2 that I need to initialize. One of the varialbles I'm trying to set to [txtRow].value which should be 20 that was passed from "myRow" on UserForm_1. But when I run the code it comes back with an error "Type mismatch". Here's my code:
Code:
Private Sub UserForm2_Initialize()
Dim wrkJet As Workspace
Dim dbsContractor As Database
Dim rst As Recordset
Dim sql As String
Dim rcArray As Variant
Dim fstName, lstName, myDOB, mySSN, myVendor, midName As String
Dim wktype, wkstatus, recCreated, recCreatedBy, dstore As String
Dim pkey As Variant
Dim lstRow As String
Dim qdfBIrec As String
Dim f As Field
Dim myCounter As Long: myCounter = 0
Dim myArray(999, 999)
Dim myrow As Long
'
myrow = txtRow.Value
'
fstName = Cells(myrow, "b").Value
lstName = Cells(myrow, "f").Value
mySSN = Cells(myrow, "i").Value
myDOB = Cells(myrow, "j").Value
myVendor = Cells(myrow, "k").Value
midName = Cells(myrow, "e").Value