By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,486 Members | 2,034 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,486 IT Pros & Developers. It's quick & easy.

Forms to Table Calculation

P: 1
We have a form that has unbound calculation fields that we want to link to a table. Both the form and the table have already been created. How should I start my Visual Basics entry? I keep trying the following and both keep giving me a syntax error when I try to open the table, or they give me an #error or ?Name in the field on the Form.
Expand|Select|Wrap|Line Numbers
  1. Dim Rs As Recordset
  2. Set Rs = CurrentDb.OpenRecordset("Issues")
  3. Rs.AddNew
  4. Rs![Total_Hrs] = Me![Total_Hours]
  5.  
  6. Rs.Update
  7. Rs.Close
  8. Set Rs = Nothing
Any Suggestions? We have altered it several ways to no avail.
Jul 28 '08 #1
Share this Question
Share on Google+
2 Replies


Dököll
Expert 100+
P: 2,364
Greetings, Dear Friend!

Just passing through; not too savvy at calculations through forms... Wondered if you could try making your calculations in a query and load to the form. I am not sure what you hope to achieve, so do stay tuned for a better answer from experts here.

You may need to grab data from one table, calculate through form, then add to table a second table, in which case I think your form may still need the assistance of a query, or intense form functions to handle the task, surely possible, I just do not know. Have you previously searched this forum on form calculation?

Hope you get it going:-)

In a bit!
Jul 28 '08 #2

Expert 100+
P: 374
We have a form that has unbound calculation fields that we want to link to a table. Both the form and the table have already been created. How should I start my Visual Basics entry? I keep trying the following and both keep giving me a syntax error when I try to open the table, or they give me an #error or ?Name in the field on the Form.
Expand|Select|Wrap|Line Numbers
  1. Dim Rs As Recordset
  2. Set Rs = CurrentDb.OpenRecordset("Issues")
  3. Rs.AddNew
  4. Rs![Total_Hrs] = Me![Total_Hours]
  5.  
  6. Rs.Update
  7. Rs.Close
  8. Set Rs = Nothing
  9.  
Any Suggestions? We have altered it several ways to no avail.
Hey HCSO:

It is normally considered poor form to store a calculated field in a database just in case you ever need to go back and recalculate that value again. It is normally preferred to calculate that value every time that particular field needs to be displayed in case that some additional values get added to the database.

Now to solve the problem you're having with the code, you're going to have to decide whether your going to manage the database connection for the form, or if you're going to let access doing it. All you're simply doing here is adding a blank record into Table Name "Issue" with the field "Total_Hrs" being posted. If you have any required fields in the table, then you're going to generate an error.

What you're going to need to do is what I suggest and simply calculate the field, that way when you come back to that record, it will display the calculated field on the form.

If you can send me what you're wanting to calculate, then I would be able to give a specific answer as to how to accomplish this.

Hope that helps,

Joe P.
Jul 28 '08 #3

Post your reply

Sign in to post your reply or Sign up for a free account.