Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
Sam Sam is offline
external usenet poster
 
Posts: 699
Default HELP: Unable to clear values for control of type text in a userfor

Hi All,

I have textboxes and comboboxes located in Frame1 and I only want to clear
values in Textboxes when a user changes Student_Id field

Here is my code so far:

Private Sub StudentId_Change()

For Each ctl In Me.Frame1.Controls
If TypeOf ctl Is TextBox Then
ctl.Value = ""
End If
Next

End Sub

For some reason the values in textboxes are not cleared, I inserted break
points and found out that the control type of Textbox is not identified and
hence passes the If statement directly to End if

Thanks in advance

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 208
Default HELP: Unable to clear values for control of type text in auserfor

Hi
Try MSForms.Textbox

regards
Paul

On Jun 1, 8:05*pm, sam wrote:
Hi All,

I have textboxes and comboboxes located in Frame1 and I only want to clear
values in Textboxes when a user changes Student_Id field

Here is my code so far:

Private Sub StudentId_Change()

* For Each ctl In Me.Frame1.Controls
* * *If TypeOf ctl Is TextBox Then
* * * * ctl.Value = ""
* * End If
*Next

End Sub

For some reason the values in textboxes are not cleared, I inserted break
points and found out that the control type of Textbox is not identified and
hence passes the If statement directly to End if

Thanks in advance


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 226
Default HELP: Unable to clear values for control of type text in a userfor

sam brought next idea :
Hi All,

I have textboxes and comboboxes located in Frame1 and I only want to clear
values in Textboxes when a user changes Student_Id field

Here is my code so far:

Private Sub StudentId_Change()

For Each ctl In Me.Frame1.Controls
If TypeOf ctl Is TextBox Then
ctl.Value = ""
End If
Next

End Sub

For some reason the values in textboxes are not cleared, I inserted break
points and found out that the control type of Textbox is not identified and
hence passes the If statement directly to End if

Thanks in advance


The default property for a textbox is 'Text', so try:
ctl.Text = ""

regards,

--
Garry

Free usenet access at http://www.eternal-september.org
ClassicVB Users Regroup! comp.lang.basic.visual.misc


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 131
Default HELP: Unable to clear values for control of type text in a userfor

If you give your controls names that depend on the type of control they are,
then you can test the name. I'm not sure if there's a "technically correct"
naming convention for the various types, but I name my textboxes with a "tbx"
prefix, followed by some word that tells me what data the control is used
for. i.e. tbxStudentName, tbxAddr1. Then your test would be:

For Each Ctrl in Me.Frame1.Controls
If Left(Ctrl.Name, 3) = "tbx" Then Ctrl.Value = ""
Next Ctrl

"sam" wrote:

Hi All,

I have textboxes and comboboxes located in Frame1 and I only want to clear
values in Textboxes when a user changes Student_Id field

Here is my code so far:

Private Sub StudentId_Change()

For Each ctl In Me.Frame1.Controls
If TypeOf ctl Is TextBox Then
ctl.Value = ""
End If
Next

End Sub

For some reason the values in textboxes are not cleared, I inserted break
points and found out that the control type of Textbox is not identified and
hence passes the If statement directly to End if

Thanks in advance

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,069
Default HELP: Unable to clear values for control of type text in a userfor

Sam,
try it this way:

Private Sub StudentId_Change()
Dim ctl As Control
Dim CtrlType As String

For Each ctl In Me.Frame1.Controls
CtrlType = TypeName(ctl)

If CtrlType = "TextBox" Then

ctl.Value = ""

End If

Next ctl

End Sub

--
jb


"sam" wrote:

Hi All,

I have textboxes and comboboxes located in Frame1 and I only want to clear
values in Textboxes when a user changes Student_Id field

Here is my code so far:

Private Sub StudentId_Change()

For Each ctl In Me.Frame1.Controls
If TypeOf ctl Is TextBox Then
ctl.Value = ""
End If
Next

End Sub

For some reason the values in textboxes are not cleared, I inserted break
points and found out that the control type of Textbox is not identified and
hence passes the If statement directly to End if

Thanks in advance

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
capture filter values from a sheet into a dropdown list in userfor sam Excel Programming 3 September 16th 09 11:33 PM
Cells will not clear - if I type 1 it comes up as 100 know matter musicgirl Excel Worksheet Functions 2 April 13th 09 06:26 PM
Unable to sum the specific cells containing both text & values Shafaq Shabieh Excel Worksheet Functions 5 November 4th 08 08:42 AM
Clear Text in Text Box control Qaspec Excel Programming 1 August 1st 06 10:21 PM
Only text values matching using index/match lookup - data type pro Stanton Excel Worksheet Functions 1 August 2nd 05 01:05 AM


All times are GMT +1. The time now is 03:29 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"