Adding data to record with an unbound textbox

G

Guest

I have a form that is based off a table called "Warnings". The form contains
2 comboboxes and a text box. The first combobox(cmbActReg) is populated from
a table(Acts/Regs). The second combobox (cmbSection) is populated with a
list based on the item selected in the first cmbx (this was done through a
combination of VBA and a query entered into the RowSource property of
cmbActReg).

Since comboboxes are not able to display more than one column of a record
source (after selection) I have set a text box (txtDescription) to display
the desired information. This text box is not bound (unbound) to the
Warnings table. As a result I am not able to stroe the information displayed
in txtDescription in the related field of the "warnings" table.

Can someone help me with this?

Z
 
D

Duncan Bachen

Zoltar54 said:
I have a form that is based off a table called "Warnings". The form contains
2 comboboxes and a text box. The first combobox(cmbActReg) is populated from
a table(Acts/Regs). The second combobox (cmbSection) is populated with a
list based on the item selected in the first cmbx (this was done through a
combination of VBA and a query entered into the RowSource property of
cmbActReg).

Since comboboxes are not able to display more than one column of a record
source (after selection)

Not sure what you are trying to accomplish here, but you can certainly
have a multicolumn combobox that displays additional data from your
underlying recordsource. It can have only one *bound* column sure, but
you can display more than one.
I have set a text box (txtDescription) to display
the desired information. This text box is not bound (unbound) to the
Warnings table. As a result I am not able to stroe the information displayed
in txtDescription in the related field of the "warnings" table.

Can someone help me with this?

So you have the value already stored somewhere (since you display it),
and now you want to store it again? That doesn't make a whole lot of
sense the way you are describing it.

That aside, what you could do is use an update query to set the value
based on the contents of the text box. This example assumes that
SomeField is a string, which is why it's enclosed in quotes.

Dim sSQL as String

sSQL = "UPDATE tblYourTable " & _
"SET tblYourTable.SomeField = '" & txtYourTextBox & "'"
doCmd.RunSQL (sSQL)

You'd put this code under a command button, or in the afterupdate event
of the combobox, or whereever was most appropriate for the update. In
other words, does it happen automatically, or does it involve
confirmation from the end user.
 
G

Guest

Thanks for the help. I agree (after looking at the database) this does not
make sens. To answer your question - I want this to happen automatically.
However..

The form I have is uder to update a table (Form name: Warnings Issued, Table
Name: Warnings issued.)

In the table I have thre fields (Act/Reg, Section, description). On the
form I have two comboboxes that are bound to the Act/Reg and ZSection fields
of the table. I also have a textbox that is unbound but will contain the
data to populate the Description field of my table.

At the momment, I have a query that will populate the second combobo
(cmbSection)9I have entered the following into the "rowSource" propoerty of
the first combobx [form]![warnings issued]![cmbactreg]) based on an item
selected from the first box (cmbActReg). The related fields in the table are
all set to have the "lookup" property.

I was thinking that perhaps I could eneter a similiar query into the
rowsource property of the Description filed of my table and just have access
prepare an autoform based on that?

I am very new to Access and am patiently waiting for a training course. I
appreciate any asistance.

Z
 

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