![]() |
Check all lsitbox entries are filled
Here is my (not working) attempt to only enable
the OKButton if all entries in col2 of the listbox are filled with text values More correctly, if there is a value in col1, then there should be some value against it in col2. Private Sub OKButton_Click() Dim i As Integer, missing As Integer lbDataCode.BoundColumn = 2 missing = 0 For i = 0 To lbDataCode.ListCount - 1 If lbDataCode.Value = "" Then missing = missing + 1 End If Next If missing 0 Then 'more values are required MsgBox ("You must complete all Fields _ in Column 2, before you exit.") OKButton.Enabled = False Else OKButton.Tag = "Selected" CancelButton.Tag = "" Me.Hide End If lbDataCode.BoundColumn = 1 End Sub How do I test for 'empty' values, please? Regards. --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.520 / Virus Database: 318 - Release Date: 18/09/2003 |
Check all lsitbox entries are filled
Private Sub OKButton_Click()
Dim i As Integer, missing As Integer 'lbDataCode.BoundColumn = 2 missing = 0 For i = 0 To lbDataCode.ListCount - 1 If lbDataCode.List(i,0) < "" and _ Trim(lbDataCode.List(i,1))="" then missing = missing + 1 End If Next If missing 0 Then 'more values are required MsgBox ("You must complete all Fields _ in Column 2, before you exit.") OKButton.Enabled = False Else OKButton.Tag = "Selected" CancelButton.Tag = "" Me.Hide End If 'lbDataCode.BoundColumn = 1 End Sub -- Regards, Tom Ogilvy "Stuart" wrote in message ... Here is my (not working) attempt to only enable the OKButton if all entries in col2 of the listbox are filled with text values More correctly, if there is a value in col1, then there should be some value against it in col2. Private Sub OKButton_Click() Dim i As Integer, missing As Integer lbDataCode.BoundColumn = 2 missing = 0 For i = 0 To lbDataCode.ListCount - 1 If lbDataCode.Value = "" Then missing = missing + 1 End If Next If missing 0 Then 'more values are required MsgBox ("You must complete all Fields _ in Column 2, before you exit.") OKButton.Enabled = False Else OKButton.Tag = "Selected" CancelButton.Tag = "" Me.Hide End If lbDataCode.BoundColumn = 1 End Sub How do I test for 'empty' values, please? Regards. --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.520 / Virus Database: 318 - Release Date: 18/09/2003 |
Check all lsitbox entries are filled
Many thanks for that.
Regards. "Tom Ogilvy" wrote in message ... Private Sub OKButton_Click() Dim i As Integer, missing As Integer 'lbDataCode.BoundColumn = 2 missing = 0 For i = 0 To lbDataCode.ListCount - 1 If lbDataCode.List(i,0) < "" and _ Trim(lbDataCode.List(i,1))="" then missing = missing + 1 End If Next If missing 0 Then 'more values are required MsgBox ("You must complete all Fields _ in Column 2, before you exit.") OKButton.Enabled = False Else OKButton.Tag = "Selected" CancelButton.Tag = "" Me.Hide End If 'lbDataCode.BoundColumn = 1 End Sub -- Regards, Tom Ogilvy "Stuart" wrote in message ... Here is my (not working) attempt to only enable the OKButton if all entries in col2 of the listbox are filled with text values More correctly, if there is a value in col1, then there should be some value against it in col2. Private Sub OKButton_Click() Dim i As Integer, missing As Integer lbDataCode.BoundColumn = 2 missing = 0 For i = 0 To lbDataCode.ListCount - 1 If lbDataCode.Value = "" Then missing = missing + 1 End If Next If missing 0 Then 'more values are required MsgBox ("You must complete all Fields _ in Column 2, before you exit.") OKButton.Enabled = False Else OKButton.Tag = "Selected" CancelButton.Tag = "" Me.Hide End If lbDataCode.BoundColumn = 1 End Sub How do I test for 'empty' values, please? Regards. --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.520 / Virus Database: 318 - Release Date: 18/09/2003 --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.520 / Virus Database: 318 - Release Date: 18/09/2003 |
All times are GMT +1. The time now is 04:21 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com