Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Save Value after run


Excel 2003 w/VBA 6.3

Have a form with several textboxes in which a user will insert values.
The names of all the textboxes start with "txt", e.g. txtLotNum.
During the course of running the program I purposely "clear" (see
below) the values from all textboxes. However, I would like to retain
the value of one of the textboxes, so that when the user starts the
program again after closing, that value already appears in the textbox
on the form. Cuts down on data entry.


Code:
--------------------
For Each Ctls In frmEasyLyteQC.Controls
If Left(Ctls.Name, 3) = "txt" Then
Ctls.Value = ""
End If
Next Ctls
--------------------


--
scantor145
------------------------------------------------------------------------
scantor145's Profile: http://www.excelforum.com/member.php...o&userid=14766
View this thread: http://www.excelforum.com/showthread...hreadid=533684

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Save Value after run

Save it in a workbook name


ThisWorkbook.Names.Add Name:="__SavedTextBox", RefersTo:="=" &
txtLotNum.Text
For Each Ctls In frmEasyLyteQC.Controls
If Left(Ctls.Name, 3) = "txt" Then
Ctls.Value = ""
End If
Next Ctls

You get it back with

myValue = Evaluate(ThisWorkbook).Names("__SavedTextBox").Ref ersTo)

--
HTH

Bob Phillips

(remove nothere from email address if mailing direct)

"scantor145" wrote
in message ...

Excel 2003 w/VBA 6.3

Have a form with several textboxes in which a user will insert values.
The names of all the textboxes start with "txt", e.g. txtLotNum.
During the course of running the program I purposely "clear" (see
below) the values from all textboxes. However, I would like to retain
the value of one of the textboxes, so that when the user starts the
program again after closing, that value already appears in the textbox
on the form. Cuts down on data entry.


Code:
--------------------
For Each Ctls In frmEasyLyteQC.Controls
If Left(Ctls.Name, 3) = "txt" Then
Ctls.Value = ""
End If
Next Ctls
--------------------


--
scantor145
------------------------------------------------------------------------
scantor145's Profile:

http://www.excelforum.com/member.php...o&userid=14766
View this thread: http://www.excelforum.com/showthread...hreadid=533684



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Save Value after run

Another option may be to just use a hidden worksheet to save all the stuff you
need.

scantor145 wrote:

Excel 2003 w/VBA 6.3

Have a form with several textboxes in which a user will insert values.
The names of all the textboxes start with "txt", e.g. txtLotNum.
During the course of running the program I purposely "clear" (see
below) the values from all textboxes. However, I would like to retain
the value of one of the textboxes, so that when the user starts the
program again after closing, that value already appears in the textbox
on the form. Cuts down on data entry.

Code:
--------------------
For Each Ctls In frmEasyLyteQC.Controls
If Left(Ctls.Name, 3) = "txt" Then
Ctls.Value = ""
End If
Next Ctls
--------------------

--
scantor145
------------------------------------------------------------------------
scantor145's Profile: http://www.excelforum.com/member.php...o&userid=14766
View this thread: http://www.excelforum.com/showthread...hreadid=533684


--

Dave Peterson
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Save Value after run


Thanks for the response , but it doesn't seem to work. I think there's
something wrong with


Code:
--------------------
myValue = Evaluate(ThisWorkbook).Names("__SavedTextBox").Ref ersTo)
--------------------


Parentheses missing?
Should there be something after RefersTo?


--
scantor145
------------------------------------------------------------------------
scantor145's Profile: http://www.excelforum.com/member.php...o&userid=14766
View this thread: http://www.excelforum.com/showthread...hreadid=533684

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Save Value after run

Looks like a space has crept in

myValue = Evaluate(ThisWorkbook).Names("__SavedTextBox").Ref ersTo

--
HTH

Bob Phillips

(remove nothere from email address if mailing direct)

"scantor145" wrote
in message ...

Thanks for the response , but it doesn't seem to work. I think there's
something wrong with


Code:
--------------------
myValue = Evaluate(ThisWorkbook).Names("__SavedTextBox").Ref ersTo)
--------------------


Parentheses missing?
Should there be something after RefersTo?


--
scantor145
------------------------------------------------------------------------
scantor145's Profile:

http://www.excelforum.com/member.php...o&userid=14766
View this thread: http://www.excelforum.com/showthread...hreadid=533684





  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Save Value after run


Thanks again, but maybe I just don't understand where to put the line
below.

I thought the idea was to somehow "save" the txtLotNum entry that had
just been entered. I placed the code below just as the program
starts.

I receive an Object required run-time error 424 message


Code:
--------------------
MyValue = Evaluate(ThisWorkbook).Names("SavedTextBox").Refer sTo
--------------------


The workbook wasn't closed, but even if it was, I thought that the
txtLotNum value was "saved" someplace.


--
scantor145
------------------------------------------------------------------------
scantor145's Profile: http://www.excelforum.com/member.php...o&userid=14766
View this thread: http://www.excelforum.com/showthread...hreadid=533684

  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Save Value after run

I didn't build the textboxes, but maybe this did work for me:

Option Explicit
Sub testme()

Dim txtLotNum As String
Dim myValue As String

txtLotNum = "hi there"

ThisWorkbook.Names.Add Name:="__SavedTextBox", RefersTo:=txtLotNum
myValue = Evaluate(ThisWorkbook.Names("__SavedTextBox").Refe rsTo)

MsgBox myValue

End Sub



scantor145 wrote:

Thanks again, but maybe I just don't understand where to put the line
below.

I thought the idea was to somehow "save" the txtLotNum entry that had
just been entered. I placed the code below just as the program
starts.

I receive an Object required run-time error 424 message

Code:
--------------------
MyValue = Evaluate(ThisWorkbook).Names("SavedTextBox").Refer sTo
--------------------

The workbook wasn't closed, but even if it was, I thought that the
txtLotNum value was "saved" someplace.

--
scantor145
------------------------------------------------------------------------
scantor145's Profile: http://www.excelforum.com/member.php...o&userid=14766
View this thread: http://www.excelforum.com/showthread...hreadid=533684


--

Dave Peterson
  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Save Value after run

You said ... so that when the user starts the
program again after closing, that value already appears in the textbox
on the form.

That piece of code will get the saved textbox value in a variable which you
can then load into your textbox on a subsequent run. You will have to decide
where to do that.

--
HTH

Bob Phillips

(remove nothere from email address if mailing direct)

"scantor145" wrote
in message ...

Thanks again, but maybe I just don't understand where to put the line
below.

I thought the idea was to somehow "save" the txtLotNum entry that had
just been entered. I placed the code below just as the program
starts.

I receive an Object required run-time error 424 message


Code:
--------------------
MyValue = Evaluate(ThisWorkbook).Names("SavedTextBox").Refer sTo
--------------------


The workbook wasn't closed, but even if it was, I thought that the
txtLotNum value was "saved" someplace.


--
scantor145
------------------------------------------------------------------------
scantor145's Profile:

http://www.excelforum.com/member.php...o&userid=14766
View this thread: http://www.excelforum.com/showthread...hreadid=533684



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
Save, save as, page setup dimmed out in unprotected excel sheet? ccKeithJ Excel Discussion (Misc queries) 3 December 14th 07 07:07 PM
Command Button Save As Application.ExecuteExcel4Macro ("SAVE.AS?() Paul Dennis Excel Discussion (Misc queries) 5 September 18th 06 05:34 PM
how to get disk icon on save button of save as dialog like 2000 RichT Excel Discussion (Misc queries) 2 March 9th 06 08:13 PM
Totally Disabling (^ save ) (Save as) and Save Icon – Which code do I use: harpscardiff[_10_] Excel Programming 8 November 10th 05 12:24 PM
Save Excel file - prompts to save - no Volitile functions used POWER CERTS Excel Worksheet Functions 2 November 1st 04 09:27 PM


All times are GMT +1. The time now is 10:40 PM.

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

About Us

"It's about Microsoft Excel"