S
Stuart
If MsgBox("Do you wish to use the Master SubContractor/" _
& "Suppliers" & vbNewLine & "trade reference codes, or" _
& "rename them again?", vbYesNo) = vbYes Then
Call DataStoreCodes(wkbkname)
Else
frmName_Contractors.lbDataCode.List = _
Workbooks(wkbkname).Worksheets _
("DataStore").Range("G1", "G" & Rows.Count).Value
With Workbooks(wkbkname).Sheets("DataStore")
.Unprotect
.Range("G1", "G" & .Rows.Count).ClearContents
End With
End If
frmName_Contractors.Show
If user choses Yes, then all is fine. The sub 'DataStoreCodes'
loads col1 in the listbox of frmName_Contractors.Show
with all the codes in the user's workbook, and then checks them
against a sheet (MasterDataStore) in an addin. If the code is in the
addin, then it's loaded into Col2 in the listbox against the relevent
item.
If user chooses No, then I cannot get it to work.
The range is correctly added into Col! of the listbox, and when the
form displays, Col2 is (correctly) empty of values.
At this point user should be able to click on a Col1 entry then go
to a textbox where they type the corresponding Col2 value.
Doing this gives an error:
"Could not get the Column property....Invalid argument"
Here is the form code:
Private Sub lbDataCode_Click()
If lbDataCode.ListIndex <> -1 Then
If lbDataCode.Column(1, lbDataCode.ListIndex) <> "" Then
tbCtrTrade.Text = lbDataCode.Column(1, lbDataCode.ListIndex)
tbCtrTrade.SetFocus
tbCtrTrade.SelStart = 0
tbCtrTrade.SelLength = Len(tbCtrTrade.Text)
Else
tbCtrTrade.Text = ""
tbCtrTrade.SetFocus
End If
Else
tbCtrTrade.Text = ""
End If
End Sub
Private Sub tbCtrTrade_AfterUpdate()
If lbDataCode.ListIndex <> -1 Then
If tbCtrTrade.Text <> "" Then
lbDataCode.Column(1, lbDataCode.ListIndex) _
= tbCtrTrade.Text
End If
End If
End Sub
How may I amend this code, please?.
Regards.
& "Suppliers" & vbNewLine & "trade reference codes, or" _
& "rename them again?", vbYesNo) = vbYes Then
Call DataStoreCodes(wkbkname)
Else
frmName_Contractors.lbDataCode.List = _
Workbooks(wkbkname).Worksheets _
("DataStore").Range("G1", "G" & Rows.Count).Value
With Workbooks(wkbkname).Sheets("DataStore")
.Unprotect
.Range("G1", "G" & .Rows.Count).ClearContents
End With
End If
frmName_Contractors.Show
If user choses Yes, then all is fine. The sub 'DataStoreCodes'
loads col1 in the listbox of frmName_Contractors.Show
with all the codes in the user's workbook, and then checks them
against a sheet (MasterDataStore) in an addin. If the code is in the
addin, then it's loaded into Col2 in the listbox against the relevent
item.
If user chooses No, then I cannot get it to work.
The range is correctly added into Col! of the listbox, and when the
form displays, Col2 is (correctly) empty of values.
At this point user should be able to click on a Col1 entry then go
to a textbox where they type the corresponding Col2 value.
Doing this gives an error:
"Could not get the Column property....Invalid argument"
Here is the form code:
Private Sub lbDataCode_Click()
If lbDataCode.ListIndex <> -1 Then
If lbDataCode.Column(1, lbDataCode.ListIndex) <> "" Then
tbCtrTrade.Text = lbDataCode.Column(1, lbDataCode.ListIndex)
tbCtrTrade.SetFocus
tbCtrTrade.SelStart = 0
tbCtrTrade.SelLength = Len(tbCtrTrade.Text)
Else
tbCtrTrade.Text = ""
tbCtrTrade.SetFocus
End If
Else
tbCtrTrade.Text = ""
End If
End Sub
Private Sub tbCtrTrade_AfterUpdate()
If lbDataCode.ListIndex <> -1 Then
If tbCtrTrade.Text <> "" Then
lbDataCode.Column(1, lbDataCode.ListIndex) _
= tbCtrTrade.Text
End If
End If
End Sub
How may I amend this code, please?.
Regards.