Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default Spinbutton Mysteriously Erases Textbox

I'm writing an employment evaluation. I have several userforms with
textbox1 and textbox2. textbox1 is a value between 0 and 3 controlled
by a spinbutton (spinbutton1), the only spinbutton on the userform.
textbox2 is a plain text entry box used for comment entry. The issue
I'm having is that if I type my comments in textbox2 first then click
either the up or down buttons on the spinbutton, textbox2 is erased.
What's strange is that if I click the spinbutton first, giving the
employee a rating, and then type in textbox2, and then go back and
click on the spinbutton, the text remains in textbox2. Essentially you
must give a rating first or you will lose any text you enter. I don't
have any code that should erase textbox2 for any reason. Both
textboxes are linked to separate cells on the same sheet. Below is the
code for the spinbutton which is the only code behind the userform.
Thanks for any advice!



Private Sub SpinButton1_SpinDown()
Sheets("calc").Select
For Each cell In ActiveSheet.Range("C57")
If TextBox1.Value 0 Then cell.Value = cell.Value - 0.1
Next
End Sub

Private Sub SpinButton1_SpinUp()
Sheets("calc").Select
For Each cell In ActiveSheet.Range("C57")
If TextBox1.Value < 3 Then cell.Value = cell.Value + 0.1
Next
End Sub

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 694
Default Spinbutton Mysteriously Erases Textbox

Hi Ryan:

I would sugget that you try and step through your code and find where the
event occurs.

Your code appears to be ok as given but it will be the other code that is
causing problems.

BTW, you don't need for each cell or the select as you are only checking one
cell and I recommend using constants for sheet names and cell addresses to
make changing easier. just use a with:

Try:

Const cszSheetName as string = "calc"
Const cszCellRef as string = "C57"

Private Sub SpinButton1_SpinDown()

With Sheets(cszSheetName).Range(cszCellRef)
If Me.TextBox1.Value 0 Then .Value = .Value - 0.1
end with
end Sub

Private Sub SpinButton1_SpinUp()
With Sheets(cszSheetName).Range(cszCellRef)
If TextBox1.Value < 3 Then .Value = .Value + 0.1
end with
End Sub


--
Hope this helps
Martin Fishlock, Bangkok, Thailand
Please do not forget to rate this reply.


" wrote:

I'm writing an employment evaluation. I have several userforms with
textbox1 and textbox2. textbox1 is a value between 0 and 3 controlled
by a spinbutton (spinbutton1), the only spinbutton on the userform.
textbox2 is a plain text entry box used for comment entry. The issue
I'm having is that if I type my comments in textbox2 first then click
either the up or down buttons on the spinbutton, textbox2 is erased.
What's strange is that if I click the spinbutton first, giving the
employee a rating, and then type in textbox2, and then go back and
click on the spinbutton, the text remains in textbox2. Essentially you
must give a rating first or you will lose any text you enter. I don't
have any code that should erase textbox2 for any reason. Both
textboxes are linked to separate cells on the same sheet. Below is the
code for the spinbutton which is the only code behind the userform.
Thanks for any advice!



Private Sub SpinButton1_SpinDown()
Sheets("calc").Select
For Each cell In ActiveSheet.Range("C57")
If TextBox1.Value 0 Then cell.Value = cell.Value - 0.1
Next
End Sub

Private Sub SpinButton1_SpinUp()
Sheets("calc").Select
For Each cell In ActiveSheet.Range("C57")
If TextBox1.Value < 3 Then cell.Value = cell.Value + 0.1
Next
End Sub


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default Spinbutton Mysteriously Erases Textbox

On Feb 11, 9:36 pm, Martin Fishlock
wrote:
Hi Ryan:

I would sugget that you try and step through your code and find where the
event occurs.

Your code appears to be ok as given but it will be the other code that is
causing problems.

BTW, you don't need for each cell or the select as you are only checking one
cell and I recommend using constants for sheet names and cell addresses to
make changing easier. just use a with:

Try:

Const cszSheetName as string = "calc"
Const cszCellRef as string = "C57"

Private Sub SpinButton1_SpinDown()

With Sheets(cszSheetName).Range(cszCellRef)
If Me.TextBox1.Value 0 Then .Value = .Value - 0.1
end with
end Sub

Private Sub SpinButton1_SpinUp()
With Sheets(cszSheetName).Range(cszCellRef)
If TextBox1.Value < 3 Then .Value = .Value + 0.1
end with
End Sub

--
Hope this helps
Martin Fishlock, Bangkok, Thailand
Please do not forget to rate this reply.

" wrote:
I'm writing an employment evaluation. I have several userforms with
textbox1 and textbox2. textbox1 is a value between 0 and 3 controlled
by a spinbutton (spinbutton1), the only spinbutton on the userform.
textbox2 is a plain text entry box used for comment entry. The issue
I'm having is that if I type my comments in textbox2 first then click
either the up or down buttons on the spinbutton, textbox2 is erased.
What's strange is that if I click the spinbutton first, giving the
employee a rating, and then type in textbox2, and then go back and
click on the spinbutton, the text remains in textbox2. Essentially you
must give a rating first or you will lose any text you enter. I don't
have any code that should erase textbox2 for any reason. Both
textboxes are linked to separate cells on the same sheet. Below is the
code for the spinbutton which is the only code behind the userform.
Thanks for any advice!


Private Sub SpinButton1_SpinDown()
Sheets("calc").Select
For Each cell In ActiveSheet.Range("C57")
If TextBox1.Value 0 Then cell.Value = cell.Value - 0.1
Next
End Sub


Private Sub SpinButton1_SpinUp()
Sheets("calc").Select
For Each cell In ActiveSheet.Range("C57")
If TextBox1.Value < 3 Then cell.Value = cell.Value + 0.1
Next
End Sub


Thanks Martin...I thought this would work but unfortunately I'm having
the same issue with your code.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default Spinbutton Mysteriously Erases Textbox

On Feb 11, 10:19 pm, wrote:
On Feb 11, 9:36 pm, Martin Fishlock



wrote:
Hi Ryan:


I would sugget that you try and step through your code and find where the
event occurs.


Your code appears to be ok as given but it will be the other code that is
causing problems.


BTW, you don't need for each cell or the select as you are only checking one
cell and I recommend using constants for sheet names and cell addresses to
make changing easier. just use a with:


Try:


Const cszSheetName as string = "calc"
Const cszCellRef as string = "C57"


Private Sub SpinButton1_SpinDown()


With Sheets(cszSheetName).Range(cszCellRef)
If Me.TextBox1.Value 0 Then .Value = .Value - 0.1
end with
end Sub


Private Sub SpinButton1_SpinUp()
With Sheets(cszSheetName).Range(cszCellRef)
If TextBox1.Value < 3 Then .Value = .Value + 0.1
end with
End Sub


--
Hope this helps
Martin Fishlock, Bangkok, Thailand
Please do not forget to rate this reply.


" wrote:
I'm writing an employment evaluation. I have several userforms with
textbox1 and textbox2. textbox1 is a value between 0 and 3 controlled
by a spinbutton (spinbutton1), the only spinbutton on the userform.
textbox2 is a plain text entry box used for comment entry. The issue
I'm having is that if I type my comments in textbox2 first then click
either the up or down buttons on the spinbutton, textbox2 is erased.
What's strange is that if I click the spinbutton first, giving the
employee a rating, and then type in textbox2, and then go back and
click on the spinbutton, the text remains in textbox2. Essentially you
must give a rating first or you will lose any text you enter. I don't
have any code that should erase textbox2 for any reason. Both
textboxes are linked to separate cells on the same sheet. Below is the
code for the spinbutton which is the only code behind the userform.
Thanks for any advice!


Private Sub SpinButton1_SpinDown()
Sheets("calc").Select
For Each cell In ActiveSheet.Range("C57")
If TextBox1.Value 0 Then cell.Value = cell.Value - 0.1
Next
End Sub


Private Sub SpinButton1_SpinUp()
Sheets("calc").Select
For Each cell In ActiveSheet.Range("C57")
If TextBox1.Value < 3 Then cell.Value = cell.Value + 0.1
Next
End Sub


Thanks Martin...I thought this would work but unfortunately I'm having
the same issue with your code.


Martin...I figured it out. My textbox was in a frame and when i
removed the frame the behavior stopped. I don;t know if it's a bug or
what. I'm going to do some more testing but the frame which was just
around textbox2 appears to have somehow been the cause. Thanks again
for the suggestion!

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
SpinButton/TextBox - Large Number John Fuller Excel Programming 3 September 21st 06 03:19 PM
Trendline erases chart name jase Charts and Charting in Excel 1 June 21st 06 11:30 PM
Excel erases the "To:" field when emailing Mike M. Excel Discussion (Misc queries) 2 September 26th 05 01:24 PM
Clicking the text in a textbox erases all the data in the box dok112[_20_] Excel Programming 4 July 27th 04 01:26 PM
Spinbutton Linked to Textbox David Reid[_2_] Excel Programming 2 August 19th 03 04:25 PM


All times are GMT +1. The time now is 10:54 AM.

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"