ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Text box value lost (https://www.excelbanter.com/excel-programming/400262-text-box-value-lost.html)

Steve C

Text box value lost
 
I've created a form that asks users to input a From: date (txtFrom) and a To:
date (txtTo) for setting a print range. The programming works flawlessly for
3 of the 4 users who use it. However, on the one computer (Kurt) where it
doesn't work, the form doesn't retain the value of the To: text box after
clicking OK. It does retain the value of the From: text box (All users are
using Excel 2003).

I have an error handler that is triggered if the user doesn't enter a To:
date. Part of my code is below. If I step through the code on any of the
other 3 user's computer after entering a To: date of 12/15/07, the
txtTo.Value = "12/15/07". But if I step through it on Kurt's computer, I get
txtTo.Value = "", which then triggers the error handler.

I'm befuddled. I checked Tools References in the VB Editor on each
computer, and all are the same. Thanks for any ideas you can give me.


Public FromDate As Date, ToDate As Date

Private Sub cmdOK_Click()

frmPrintRange.Hide
FromDate = txtFrom.Value 'today's date automatically entered here upon
loading of form
On Error GoTo ErrorHandler 'if To: date is not entered
ToDate = txtTo.Value

'code that sets print range

ErrorHandler:
MsgBox "No To: date was indicated. Try again.", vbOKOnly, "Error"
Unload Me
Exit Sub

--
Steve C

JLGWhiz

Text box value lost
 
Steve, the problem obviously is not in the code. Check Kurt's worksheet for
a Worksheet_Change code that deletes the date entry or sets the cell value to
null. The problem is somewhere in Kurt's system.

"Steve C" wrote:

I've created a form that asks users to input a From: date (txtFrom) and a To:
date (txtTo) for setting a print range. The programming works flawlessly for
3 of the 4 users who use it. However, on the one computer (Kurt) where it
doesn't work, the form doesn't retain the value of the To: text box after
clicking OK. It does retain the value of the From: text box (All users are
using Excel 2003).

I have an error handler that is triggered if the user doesn't enter a To:
date. Part of my code is below. If I step through the code on any of the
other 3 user's computer after entering a To: date of 12/15/07, the
txtTo.Value = "12/15/07". But if I step through it on Kurt's computer, I get
txtTo.Value = "", which then triggers the error handler.

I'm befuddled. I checked Tools References in the VB Editor on each
computer, and all are the same. Thanks for any ideas you can give me.


Public FromDate As Date, ToDate As Date

Private Sub cmdOK_Click()

frmPrintRange.Hide
FromDate = txtFrom.Value 'today's date automatically entered here upon
loading of form
On Error GoTo ErrorHandler 'if To: date is not entered
ToDate = txtTo.Value

'code that sets print range

ErrorHandler:
MsgBox "No To: date was indicated. Try again.", vbOKOnly, "Error"
Unload Me
Exit Sub

--
Steve C


Steve C

Text box value lost
 
That's what I was suspecting. I will try your suggestion. Thanks!
--
Steve C


"JLGWhiz" wrote:

Steve, the problem obviously is not in the code. Check Kurt's worksheet for
a Worksheet_Change code that deletes the date entry or sets the cell value to
null. The problem is somewhere in Kurt's system.

"Steve C" wrote:

I've created a form that asks users to input a From: date (txtFrom) and a To:
date (txtTo) for setting a print range. The programming works flawlessly for
3 of the 4 users who use it. However, on the one computer (Kurt) where it
doesn't work, the form doesn't retain the value of the To: text box after
clicking OK. It does retain the value of the From: text box (All users are
using Excel 2003).

I have an error handler that is triggered if the user doesn't enter a To:
date. Part of my code is below. If I step through the code on any of the
other 3 user's computer after entering a To: date of 12/15/07, the
txtTo.Value = "12/15/07". But if I step through it on Kurt's computer, I get
txtTo.Value = "", which then triggers the error handler.

I'm befuddled. I checked Tools References in the VB Editor on each
computer, and all are the same. Thanks for any ideas you can give me.


Public FromDate As Date, ToDate As Date

Private Sub cmdOK_Click()

frmPrintRange.Hide
FromDate = txtFrom.Value 'today's date automatically entered here upon
loading of form
On Error GoTo ErrorHandler 'if To: date is not entered
ToDate = txtTo.Value

'code that sets print range

ErrorHandler:
MsgBox "No To: date was indicated. Try again.", vbOKOnly, "Error"
Unload Me
Exit Sub

--
Steve C



All times are GMT +1. The time now is 05:12 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com