View Full Version : Solved: save problem

07-12-2012, 02:35 PM
i have a multipage form with combo's, text, etc and when I save does not store anything... on open is blank.. like brand new... sugestions

07-12-2012, 09:28 PM
That's right. Userform's do not store any of their data. You have to 'refresh' it after every start.

07-13-2012, 12:45 AM
ok so what do I need to do store the data? use beforesave? and when start how do I "refresh" with activate?

07-13-2012, 02:10 AM
Have a good look here at Debra's excellent web site

07-13-2012, 06:51 AM
sorry but the site is too extensive to look for...
can anyone help in this exactly?

07-13-2012, 07:43 AM
So, in your other thread (http://www.vbaexpress.com/forum/showthread.php?t=42919), Zack was showing you how to populate the combobox. Just before closing the form, you need to write the data back to the spreadsheet. Normally I have a Save Or Exit Commandbutton to close the userform. Let's say that button is named cmdSave.

Private Sub cmdSave_Click()
Sheet2.Range("A1").value = ComboBox1.value
Unload Me
End Sub

07-13-2012, 09:56 AM
sorry but (forgetting the other thead) new form with several things... and when I make save by click as

Sub SaveDocument()
End Sub

it does not store anything of what I've written... :( need something here?
I just create the form and the textboxes.... probably I have a simple problem but as new in this.... sorry

07-13-2012, 02:11 PM
No, this has to be BEFORE you close the userform. The code I suggested should be on the userform code page.

07-14-2012, 01:19 PM
that means to write in a worksheet...is not any other way to store things?

07-14-2012, 01:27 PM
You can use document variables.
You can use built-in documernt variable, like Subject, author, etc. I tend to use these as you can go to document properties and edit them if you need.
You can store the data in an external file. E.g. Just a simple text file. Then on exit, delete the file. Or a Random access file. Kinda like a text file, but very difficult to recognize data.
You can write them to a hidden sheet, or a obscure location, like ZZZ999.

07-14-2012, 01:35 PM
and with document variables how do I do it? or in the hidden sheet(can it be xlveryhiddeen)?
(I prefer the 1st)


07-14-2012, 01:57 PM
Here's an example. (http://social.msdn.microsoft.com/Forums/en-AU/exceldev/thread/edecba00-8fc9-4237-a17a-ed17f6f2ca0f)
Sub test()
Dim wb As Workbook
Dim docProps As DocumentProperties
Dim docProp As DocumentProperty
Set wb = ActiveWorkbook
Set docProps = wb.CustomDocumentProperties

With docProps
.Add Name:="CustomNumber", _
LinkToContent:=False, _
Type:=msoPropertyTypeNumber, _
.Add Name:="CustomString", _
LinkToContent:=False, _
Type:=msoPropertyTypeString, _
Value:="This is a custom property."
.Add Name:="CustomDate", _
LinkToContent:=False, _
Type:=msoPropertyTypeDate, _
End With
For Each docProp In docProps
Debug.Print docProp.Name, docProp.Value

End Sub

in the hidden sheet(can it be xlveryhiddeen)?Yes

07-14-2012, 02:12 PM
sorry I'm to new to this loool
what is document properties and where the hell are they?
using excel 2007

07-14-2012, 04:48 PM
What are the control names (textbox?) and what type of value are they?

07-14-2012, 05:00 PM
after cracking my head made a sheet xlveryhidden and putted info there and got it back to the form's

thanks everyone