473,503 Members | 1,804 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Forms to Table Calculation

1 New Member
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
2 1668
Dököll
2,364 Recognized Expert Top Contributor
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
PianoMan64
374 Recognized Expert Contributor
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

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

Similar topics

0
1599
by: maceo | last post by:
I have some code that extracts the data from a table and performs a calculation (total time) on one of the columns. Here is the code: <?php /* Database connection */
1
11336
by: Jaime Stuardo | last post by:
Hi all... I have a table that will never change. Specifically it's a mortality chart that I need to use to make some calculations. One column of the table is the age of the person, and other...
6
6452
by: Otie | last post by:
I have a project with a main form and a second form with a grid on it. Neither form is an MDI, thus neither form is a child - they are two independent forms. The CALCULATE button on the main form...
1
2269
by: chris vettese | last post by:
I'm looking for advice on how to perform calculations on my forms. Iwill try to explain the situation as clearly as possible. I have a form that has multiple sub-forms. Some of these sub-forms...
0
1846
by: leavandor | last post by:
I am trying to design a query that works with a relationship between a Table and a Query. I am comparing a value in the table with a computed value inside the query. The reason for this is that...
4
2103
by: lifang85 | last post by:
hi I have a large DB and the user will enter the values in the fields (1st form) and at the end of the day, there is another form (2nd) will get and compute all the values, calculate the diff...
10
3136
by: Coleen | last post by:
Hi all :-) I have a weird formatting problem with an HTML table that I am populating using VB.Net and HTML. Here is the snippet of code for the cell I'm trying to format: Dim...
8
2161
by: TORQUE | last post by:
Hi, I am having some trouble with recording a field on a form into my Table after formatting it to calculate several fields on the form. If i just put the amount in the field and have it linked...
9
4992
by: Mohd Al Junaibi | last post by:
Hello all, my first post here...hope it goes well. I'm currently working on stored procedure where I translated some reporting language into T-SQL The logic: I have a group of tables...
0
7199
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7323
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6984
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5576
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5005
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4670
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3162
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3151
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
377
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.