storing input

G

Guest

This is just a general question. I have a userform with all types of
controls (text boxes, comboboxes, option buttons....) I want to store the
user's input each time they run through the program. If it is a combobox, I
store the value of the combobox. Same as with a text box. My question is
what is the best way to store check box or option button values?

For example. If I have two option buttons, obIncludeFreight and
obFreightNotIncluded. In my excel database, I have one column that is titled
Freight. If obIncludeFreight was checked, I store "True" in this column. Is
this the best way to store this type of data? How would I handle it in the
future if i need to change this to a combobox or different type of control?

Thanks,
Steve
 
S

smw226 via OfficeKB.com

Hi Steve,

Contained in your questions is quite a contradiction in terms....the words
Excel and Database really don't belong together. Before Database you
normally see Access and with Access your form will be controlled by a table
which will automatically store the data there for you.

However, most companies (and people) have an overtion to Access so with a bit
of code you can solve your problem.

Paste the below onto your submit button action...it could be classed as
verbose, but for the amount you will need it doesn't really matter. I would
handle your friehgt/non-freight but having the button updating a hidden text
box and "IF Hidden_box = 1,then A2=Ture, Else A2 = False end if"

Private Sub CommandButton1_Click()

Dim row1 As Long

Range("A65536").Select
Selection.End(xlUp).Select
row1 = ActiveCell.Row


Range("A" & (row1 + 1)).Select
ActiveCell.Value = UserForm1.TextBox1

Range("B" & (row1 + 1)).Select
ActiveCell.Value = UserForm1.TextBox2

End Sub

HTH

Simon
This is just a general question. I have a userform with all types of
controls (text boxes, comboboxes, option buttons....) I want to store the
user's input each time they run through the program. If it is a combobox, I
store the value of the combobox. Same as with a text box. My question is
what is the best way to store check box or option button values?

For example. If I have two option buttons, obIncludeFreight and
obFreightNotIncluded. In my excel database, I have one column that is titled
Freight. If obIncludeFreight was checked, I store "True" in this column. Is
this the best way to store this type of data? How would I handle it in the
future if i need to change this to a combobox or different type of control?

Thanks,
Steve

--
--------------------
Simon - UK

Email at simon22mports [ a t ] hot mail [ d ot ]com

Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.aspx/excel-programming/200610/1
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top