Hi guys,
I'm stuck in this one. I want to view some textboxes in my form, and add them into a listbox, but I need to take care of empty textboxes.
This is the code I currently use, but it only works if all textboxes are filled.
Thanks in advance...
Please can someone help me?!
Stefan
I'm stuck in this one. I want to view some textboxes in my form, and add them into a listbox, but I need to take care of empty textboxes.
This is the code I currently use, but it only works if all textboxes are filled.
Thanks in advance...
Code:
Private Sub Form_Load()
Dim strMsg As String
Dim entity1 As String
Dim entity2 As String
Dim entity3 As String
Dim entity4 As String
Dim entity5 As String
Dim test1 As String
entity1 = Forms!Clients!entity1
entity2 = Forms!Clients!entity2
entity3 = Forms!Clients!entity3
entity4 = Forms!Clients!entity4
entity5 = Forms!Clients!entity5
If IsNull(entity1) Then
Me!test = "1 is empty"
ElseIf IsNull(entity2) Then
Set lst2 = Me!lijst
With lst2
.RowSourceType = "Value List"
.AddItem entity1
.ColumnCount = 1
End With
ElseIf IsNull(entity3) Then
Set lst3 = Me!lijst
With lst3
.RowSourceType = "Value List"
.AddItem entity1
.AddItem entity2
.ColumnCount = 1
End With
Me!test = "3 is leeg"
ElseIf IsNull(entity4) Then
Set lst4 = Me!lijst
With lst4
.RowSourceType = "Value List"
.AddItem entity1
.AddItem entity2
.AddItem entity3
.ColumnCount = 1
End With
Me!test = "4 is leeg"
ElseIf IsNull(entity5) Then
Set lst5 = Me!lijst
With lst5
.RowSourceType = "Value List"
.AddItem entity1
.AddItem entity2
.AddItem entity3
.AddItem entity4
.ColumnCount = 1
End With
Me!test = "5 is leeg"
Else
Set lst6 = Me!lijst
With lst6
.RowSourceType = "Value List"
.AddItem entity1
.AddItem entity2
.AddItem entity3
.AddItem entity4
.AddItem entity5
.ColumnCount = 1
End With
Me!test = "all filled"
End If
End Sub
Please can someone help me?!
Stefan