Calculated text box to table

  • Thread starter Bill_Green via AccessMonster.com
  • Start date
B

Bill_Green via AccessMonster.com

Hello, I have a form that gathers information from several different sources,
with the end result being calculated in a series of 36 text boxes (1 each for
36 months). We make choices via option buttons that effect this final
calculation (if it matters there are several dozen other text boxes that pull
data from queries), then we'd like to save the result of these calculations
to a table, then go to the next item (there are 65 items) and save that one,
and so on. I have a button on the form that the user would click to send it
to the table, but it is obviously not doing anything at the moment. I am
somewhat familiar with VBA, which I assume would be the best way to make this
work, but am struggling some with this. Any help would be appreciated, and
thank you in advance.
 
A

Arvin Meyer MVP

Something like:

Dim db As DAO.Database
Dim rst As Recordset

Set db = CirrentDb
Set rst = db.OpenRecordset("YourTable")
With rst
.AddNew
!FieldName = Me.txtCalculationResults
.Update
End With

rst.Close
Set rst = Nothing
Set db = Nothing

ought to do it. Be sure that you need to save the calculated value. In most
cases you do not.
 
B

Bill_Green via AccessMonster.com

Well, perhaps I should have said I'm familiar with VBA in Excel, which while
it's similar has some different aspects just because of what it's working
with. My table name is "Curve_Output" and I set the name of the columns to
"Curve %" and "Curve $". The first textbox I have with a value in the Curve %
boxes is Text272 (there are 72 boxes, not 36. 36 each of the % and the $). I
put the code below on the button and replaced "YourTable" with my table name,
then played around with the field and textbox names trying to get it to work
with no luck. I'm sorry but could you give me a little more info on where to
go from here?

I've learned the basics of queries and some VBA with Access, but still have
some to go apparently. I do appreciate your help.
Something like:

Dim db As DAO.Database
Dim rst As Recordset

Set db = CirrentDb
Set rst = db.OpenRecordset("YourTable")
With rst
.AddNew
!FieldName = Me.txtCalculationResults
.Update
End With

rst.Close
Set rst = Nothing
Set db = Nothing

ought to do it. Be sure that you need to save the calculated value. In most
cases you do not.
Hello, I have a form that gathers information from several different
sources,
[quoted text clipped - 14 lines]
work, but am struggling some with this. Any help would be appreciated, and
thank you in advance.
 
B

Bill_Green via AccessMonster.com

Wait! I think I got it! I needed to put the brackets around the recordset and
there was a typo in your solution. Thank you VERY much for your help.

Bill_Green said:
Well, perhaps I should have said I'm familiar with VBA in Excel, which while
it's similar has some different aspects just because of what it's working
with. My table name is "Curve_Output" and I set the name of the columns to
"Curve %" and "Curve $". The first textbox I have with a value in the Curve %
boxes is Text272 (there are 72 boxes, not 36. 36 each of the % and the $). I
put the code below on the button and replaced "YourTable" with my table name,
then played around with the field and textbox names trying to get it to work
with no luck. I'm sorry but could you give me a little more info on where to
go from here?

I've learned the basics of queries and some VBA with Access, but still have
some to go apparently. I do appreciate your help.
Something like:
[quoted text clipped - 20 lines]
 

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