Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Saving data in userforms on action

I am using a userform with listboxes that the user enters data into and than
another userform that returns the calculated results. I would like to know
the code to retain text that was entered in each listbox (in the registry or
whatever) on the press of an action button.

Here is JW's solution but I get an error improper use of Me function or
something similar when I use it.

'Sub Getdefaults()

' Dim ctl As Control
' Dim Ctrltype As String

' For Each ctl In Me.Controls
'Ctrltype = TypeName(ctl)
'If Ctrltype = "Textbox" Or _
'"Combobox" Or _
'"Optionbox" Or _
'"Checkbox" Or _
'"Spinbutton" Then
'ctl.Value = GetSetting _
'(APPNAME, "Defaults", ctl.Name, ctl.Value)
'End If
'Next ctl
'End Sub
'Sub SaveDefaults()

' Dim ctl As Control
' Dim Ctrltype As String

' For Each ctl In Me.Controls
'Ctrltype = TypeName(ctl)
'If Ctrltype = "Textbox" Or _
'"Combobox" Or _
'"Optionbox" Or _
'"Checkbox" Or _
'"Spinbutton" Then
'SaveSetting APPNAME, _
'"Defaults", ctl.Name, ctl.Value
'End If
'Next ctl
'End Sub

Any thoughts?

Thanks in advance


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Saving data in userforms on action


-----Original Message-----
I am using a userform with listboxes that the user

enters data into and than
another userform that returns the calculated results. I

would like to know
the code to retain text that was entered in each listbox

(in the registry or
whatever) on the press of an action button.

Here is JW's solution but I get an error improper use of

Me function or
something similar when I use it.

'Sub Getdefaults()

' Dim ctl As Control
' Dim Ctrltype As String

' For Each ctl In Me.Controls
'Ctrltype = TypeName(ctl)
'If Ctrltype = "Textbox" Or _
'"Combobox" Or _
'"Optionbox" Or _
'"Checkbox" Or _
'"Spinbutton" Then
'ctl.Value = GetSetting _
'(APPNAME, "Defaults", ctl.Name, ctl.Value)
'End If
'Next ctl
'End Sub
'Sub SaveDefaults()

' Dim ctl As Control
' Dim Ctrltype As String

' For Each ctl In Me.Controls
'Ctrltype = TypeName(ctl)
'If Ctrltype = "Textbox" Or _
'"Combobox" Or _
'"Optionbox" Or _
'"Checkbox" Or _
'"Spinbutton" Then
'SaveSetting APPNAME, _
'"Defaults", ctl.Name, ctl.Value
'End If
'Next ctl
'End Sub

Any thoughts?

Thanks in advance


Hi,

You just have a slight error in your If statement. You
cannot say for example:-

IF A=1 or 2 or 3 then B=2

You need to say

IF A=1 or A=2 or A=3 then B=2.

Here is the code I used. Notice that I specified Option
Compare Text (because Textbox2<TextBox2 otherwise) and
defined APPNAME.

Regards,
Daniel
http://www.danielklann.com

Option Compare Text
Const APPNAME = "My App"

Sub Getdefaults()

Dim ctl As Control
Dim Ctrltype As String

For Each ctl In Me.Controls
Ctrltype = TypeName(ctl)
If Ctrltype = "Textbox" Or _
Ctrltype = "Combobox" Or _
Ctrltype = "Optionbox" Or _
Ctrltype = "Checkbox" Or _
Ctrltype = "Spinbutton" Then
ctl.Value = GetSetting _
(APPNAME, "Defaults", ctl.Name,
ctl.Value)
End If
Next ctl
End Sub
Sub SaveDefaults()

Dim ctl As Control
Dim Ctrltype As String

For Each ctl In Me.Controls
Ctrltype = TypeName(ctl)
If Ctrltype = "Textbox" Or _
Ctrltype = "Combobox" Or _
Ctrltype = "Optionbox" Or _
Ctrltype = "Checkbox" Or _
Ctrltype = "Spinbutton" Then
SaveSetting APPNAME, _
"Defaults", ctl.Name, ctl.Value
End If
Next ctl
End Sub



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
Excell copy action pauses for 15 second for the smallest action Meekal Excel Discussion (Misc queries) 1 January 28th 10 04:30 PM
VBA to run every month and sorting data from userforms Phin Excel Discussion (Misc queries) 1 January 26th 07 11:37 AM
Saving Information on Userforms Bob Phillips[_6_] Excel Programming 3 May 7th 04 12:38 AM
UserForms and Variables and Types of data Larry Levinson Excel Programming 6 April 23rd 04 04:02 PM
Userforms - Dealing with zeros and non-entry of data TroyB[_2_] Excel Programming 2 November 24th 03 05:10 AM


All times are GMT +1. The time now is 04:46 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"