473,795 Members | 3,279 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Using subtotal pulled from subform in calculations on main form

9 New Member
I have a subform that totals a subtotal in the form footer. It works fine. I then pull that value onto the main form into a textbox called Subtotal2 by setting the control source =OrderSubform.F orm!Subtotal and it seems to work fine.

When I try to reference the Subtotal2 text box to perform calculations on it it doesn't work. For instance when in vba I set Me.tax = Me.Subtotal2 * TaxRate I get zero. I tried just saying Me.tax = Me.Subtotal2 to see if thats where the problem is and it is still zero. If I change it to Me.tax = 50 it comes out as 50 so I know the code is executing. Any ideas? The Subtotal2 box displays the correct subtotal but the vba code seems to think it is zero.
Oct 21 '09 #1
12 4305
etmanage
9 New Member
Does anyone have any ideas? I'm at an impass until I figure this out and I've tried everything I can think of. I tried requeries, refreshes, afterupdates etc but nothing seems to work.
Oct 21 '09 #2
NeoPa
32,579 Recognized Expert Moderator MVP
Nothing obvious springs to mind. May I suggest posting your database as an attachment. I rarely suggest this, but your problem is intriguing and I can only imagine determining the problem with direct, hands-on, access to the project.

When attaching your work please follow the following steps first :
  1. Remove anything not relevant to the problem. This is not necessary in all circumstances but some databases can be very bulky and some things do not effect the actual problem at all.
  2. Likewise, not entirely necessary in all cases, but consider saving your database in a version not later than 2003 as many of our experts don't use Access 2007. Largely they don't want to, but some also don't have access to it. Personally I will wait until I'm forced to before using it.
  3. If you've done anything in steps 1 or 2 then make sure that the problem you're experiencing is still evident in the updated version.
  4. Compact the database.
  5. Compress the database into a ZIP file.
  6. When posting, scroll down the page and select Manage Attachments (Pressing on that leads you to a page where you can add or remove your attachments. It also lists the maximum file sizes for each of the allowed file types.) and add this new ZIP file.

While I'm here I will just mention that bumping a thread before at least 24 hours has passed is considered impatient and not too well appreciated. I can see you're new so I won't worry about it now, but please remember if you intend to continue to use the service. A full list of our rules can be found under the Help link on every page.

Welcome to Bytes!
Oct 21 '09 #3
etmanage
9 New Member
Thank you for the reply. I deleted everything that wasn't relevant. The form in question is OrderForm. When you open it, at the top are some dropdowns for dept, item, size etc. Choose something to buy and press add item, it then is added to the transactions table and appears in the subform below. The subtotal appears under the subform in a textbox called Subtotal2 and updates correctly. In the VBA code, the relevant code is in the Private Sub AddButton_Click () section. After the addbutton is pressed, the subform is requeried and then I try setting Me.Total = Me.Subtotal2 which doesn't work. I simplified this by taking out the tax line, but the root problem is the same.
I also tried adding a Private Sub Subtotal2_After Update() section with the Me.Total = Me.Subtotal2 code but that doesn't work either.

I am using Access 2003
Attached Files
File Type: zip register.zip (57.0 KB, 223 views)
Oct 22 '09 #4
NeoPa
32,579 Recognized Expert Moderator MVP
It looks like you've made a fine job of this. I'm impressed.

I can't start now to look at this though as time is getting on (01:27) and I need to wind up for the night. I'll keep it linked to look at again tomorrow though.
Oct 22 '09 #5
etmanage
9 New Member
Thank you for taking the time and for the compliment.
Oct 22 '09 #6
NeoPa
32,579 Recognized Expert Moderator MVP
It complained of a Missing reference first time, but it was obviously 2007 and the reference to the Outlook library hadn't been updated. I worked it out though so I have it working now. Just looking at it so I should post again soon.
Oct 23 '09 #7
NeoPa
32,579 Recognized Expert Moderator MVP
Ah. The control is never updated ;) The event is never triggered as the contents of the cell doesn't change as such. The value does, but the formula doesn't. Check out the Help system for the AfterUpdate event (from the help for the property click on the link to the event).

It explains that changes made by VBA do not trigger the event. It should really explain it such that only manual updates by the operator trigger the event.

I hope this clarifies the issue for you.
Oct 23 '09 #8
etmanage
9 New Member
I suspected the Subtotal2_After Update() wasn't triggering, but the AddButton_Click () event definately is and the Me.Total = Me.Subtotal2 code is there as well. It definately executes because when I substitute a value, such as 50 so that it reads Me.Total = 50 the Total textbox changes to 50. But when it is set to Me.Total = Me.Subtotal2 and the Subtotal2 textbox is 50 the Total textbox remains zero.


Edited typo please reread as it made no sense before I fixed it.
Oct 23 '09 #9
etmanage
9 New Member
Is it possible that the code is executing the Me.Total = Me.Subtotal2 before the subform has completed updating on the previous line? If so, is there a way to delay that line from executing a few milliseconds? I think this may be happening because when I add a second button that executes VBA code that sets Me.Total = Me.Subtotal2 and press that button after pressing the AddButton, it updates correctly, presumably after the subform has had enough time to requery. This is a combersome fix though, requiring the user to click two buttons to perform one task. I would much rather have a way to delay the execution of the Me.Total = Me.Subtotal2 line in the AddButton_Click () event code.
Oct 23 '09 #10

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

Similar topics

1
3585
by: Txsg8r | last post by:
I have a main form with a subform on it. When I click a button on the main form, I perform some calculations on data contained in the subform's table (all related records actually). However, after the data is massaged, I refresh it, which takes me to the first record on the subform. Instead, I need to return to the record I had showing on the subform when I clicked the button on the main form. Example: Customer= Main form. Orders =...
3
5883
by: Charlene | last post by:
I have an Invoice/Invoice Details form/subform. In the page footer of the Invoice Details subform I have a textbox with the control source set to =Sum(). I then pull this value into the main form with a textbox whose control source is =!. This works fine when there are one or more line items in Invoice Details but on a new invoice before any invoice details are entered, the textbox on the main form shows #Error. I would like it to show...
1
4443
by: phaddock4 | last post by:
Being fairly inexperienced at Access 2000, i've been reading many posts here for the last several days, and testing myself to find the best approach to do the following in A2K: SET UP: I have created a MainTable (and related form), which has an associated SubForm (popup) along with its underlying, separate Table. The tables' relationship is one to many respectively. The primary key
3
2758
by: google | last post by:
I'm developing an application for use within my company in Access 2003. I'm new to '03, the application I did for my former employer was in '97. The two applications have similar functionality (we're sales offices, and I'm doing things such as associate directories, commission calculations, order tracking, etc.). 2003 seems to have a few extra features, but I seem to continually run in to oddities that seem like they SHOULD work, but...
3
1931
by: panwala_bhavesh | last post by:
I have a subform in continuous form style that I use to populate 3 fields (textboxes) on my main form with a double-click of the key-field textbox of the sub: Private Sub TextBattID_DblClick(Cancel As Integer) Forms!. = Me! Forms!. = Me! Forms!. = Me! End Sub
0
1695
by: robert.waters | last post by:
Hello, Say that there is a database for client information; there is a main form that displays the client's name, and this form has one or more subforms that display different types of information related to that client. The main Form has RecordSource="SELECT clientid, clientname FROM client_table;", and each subform has both Link Child and Master Fields="clientid".
5
3239
by: vsteshenko | last post by:
Hello, This is my second post to the any usernet group and the first one was posted to the wrong one. I am currently working on creating an order form for sales associates at my work to be used at conventions. I have a main form with two subforms. On the main form, there is a text box that displays the sum of total orders entered in the subform, . I'm trying to create another text box on the main form, that looks at the subtotal...
3
2234
by: xian2 | last post by:
Hi All, I am trying to create a subtotal text box much like the one in the orders form of the northwind database where you have a subtotal text box in the footer of the subform and then have that displayed as a text box in the main form. However, I am having difficulties in doing this and keep getting #Error or #Name? displayed in it. Any Ideas would be much appreciated. Background info: Form = Tours
1
3106
by: lawton | last post by:
Source: this is an access 2003 question My knowledge level: reading books, internet, and trial & error; no formal training I'm trying to get a running sum of what's filtered in a subform which is ultimately driven by the results of two combo boxes: 1st combo box on main form that filters desired results for 2d combo box on sub form Main form: no record source. Has an unbound combo box. name: frminput combo name: cboAccounts The row...
0
9672
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10435
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10213
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10163
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9037
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6779
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5436
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4113
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2920
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.