Disappering CommandButton Doesn't

M

Minitman

Greetings,

I have a CommandButton on a UserForm that is supposed to become not
visible if a TextBox has anything in it. It stays visible no matter
what is in the TextBox. Here is the code I am using:
_________________________________________________________________
Public Sub I3Refresh()
Dim i As Integer

'Reload all TextBoxes from the value in I_3.List(I_3.ListIndex, 1)
'when I_3 changes
For i = 1 To 105
Select Case i
Case 2 'Invoice number
I_2 = I_3.List(I_3.ListIndex, 1)
Select Case I_2.Value
Case vbNullString 'Invoice number is NOT present
MsgBox "I_2 is Empty" & I_2
btnNextInvNumber.Visible = True
Case Else 'Invoice number is present
MsgBox "I_2 Has A Number" & I_2
btnNextInvNumber.Visible = False '<<<<<<<<<
MsgBox "Next Invoice Number should be invisible"
End Select
Case 3 'Special case
CRefName.Value = _
I_3.List(I_3.ListIndex, 2)
Case Else 'Normal data transfer
Me.Controls("I_" & i) = _
I_3.List(I_3.ListIndex, i - 1)
End Select
Next i

End Sub
_________________________________________________________________

If anything is in the TextBox called I_2 then the CommandButton
(btnNextInvNumber) which is sitting in the same space as the TextBox
needs to become not visible so that the user can see the Invoice
number. And if the TextBox has nothing to show, then the empty
TextBox should be covered with the CommandButton, until there is
something in the TextBox.

The MsgBoxes on either side of the visible code both fire at the
appropriate times, the visible code doesn't seem to fire!!!

Does anyone see anything that could be wrong with this line?

btnNextInvNumber.Visible = False

I rechecked the name of the button and it is correct.

Any help would be greatly appreciated.

-Minitman
 
P

papou

Hello
Where did you put your code module or userform?
Anyway, I would recommend you fully qualify your control in the code.
eg:
UserForm1.btnNextInvNumber.Visible = False

HTH
Cordially
Pascal
 
M

Minitman

Found it!!!

One of the logic chains got twisted

Found it when I added more MsgBoxes around every time that the button
was mentioned. I then ran the code noting when the button was and was
not visible. I found the bad section and corrected it and now it
works.

There was no problem with the code I had posted, it was in a different
section that I had forgotten about. (I just hate growing old!!!)

-Minitman
 
M

Minitman

Hey Pascal,

Thanks for the reply. It is appreciated.

I found the problem as noted in my second post on the thread. I see
that we both posted at same time. :^}

-Minitman
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top