View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Zarch Zarch is offline
external usenet poster
 
Posts: 22
Default Control names on userform

Hi Matthew,

Thanks for your reply. Yes I have tried using the .Value property, and also
removing the frame. Its strange that the other textboxes are being pikced up
correctly.

Regards,

Z

"Matthew Pfluger" wrote:

The fact that the control is in a frame could have some impact. I generally
avoid putting controls in frames whenever possible. I have been burned by
them too many times before.

Also, have you tried using the .VALUE property instead of .TEXT? I'm not
sure, but that also might fix the problem.

HTH,
Matthew Pfluger

"Zarch" wrote:

Hello again :-)

I have a userform on which there are some textboxes which I wish to check
whether or not they are blank. I am using a function, and passing the name of
the userform into it as FormToCheck. I have inserted the debug.print line in
the code while trying to fix my issue.

Function CheckForBlanks(FormToCheck)

' Checks form for blank entries

Dim Tbx As Control

CheckForBlanks = False

For Each Tbx In FormToCheck.Controls

Debug.Print Tbx.Name

If TypeName(Tbx) = "TextBox" Then
If Tbx.Text = "" Then ' Check if textbox is empty
MsgBox "Please fill in all fields"
CheckForBlanks = True
Exit Function
End If
End If
Next Tbx

End Function

The code seems to miss two of the textboxes called tbxChangeFormStartDate
and tbxChangeFormEndDate - instead it returns the names as Textbox1 and
Textbox2 and considers them as empty even when there is data on the form.

If I debug.print tbxChangeFormStartDate.text then I get the value in it!

Also I have a SpinButton named SpinButton1 (the default), but this shows as
SpinButton2 in the debug.print when the code runs.

What have I missed? Are the names for the textboses too long? They are in a
frame - could this affect things?

Many thanks,

Z