PDA

View Full Version : Solved: save problem



fgarcia90
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

Tinbendr
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.

fgarcia90
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?

Aussiebear
07-13-2012, 02:10 AM
Have a good look here at Debra's excellent web site
http://www.contextures.com/exceldataentryupdateform.html

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

Tinbendr
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

fgarcia90
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()
Application.ActiveWorkbook.Save
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

Tinbendr
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.

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

Tinbendr
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.

fgarcia90
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)

thanks

Tinbendr
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, _
Value:=1000
.Add Name:="CustomString", _
LinkToContent:=False, _
Type:=msoPropertyTypeString, _
Value:="This is a custom property."
.Add Name:="CustomDate", _
LinkToContent:=False, _
Type:=msoPropertyTypeDate, _
Value:=Date
End With
For Each docProp In docProps
Debug.Print docProp.Name, docProp.Value
Next

End Sub



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

fgarcia90
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

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

fgarcia90
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