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.
-
Dim Rs As Recordset
-
Set Rs = CurrentDb.OpenRecordset("Issues")
-
Rs.AddNew
-
Rs![Total_Hrs] = Me![Total_Hours]
-
-
Rs.Update
-
Rs.Close
-
Set Rs = Nothing
-
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.