473,835 Members | 1,965 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Base the value of a control in a form on another calculated control of same form

67 New Member
I have tried using the SetValue Macro to assign the value of a calculated control to another BOUND Control on the same form but have not been successful. I followed the exact format shown in MS Access help instructions.
The amount appears properly in the unbound text box (derived from data in a subform within the same form), however I cannot get that amount to then appear in a Bound Control's text box using the SetValue macro.
I am only doing it this way, since I do not know how to attach a calculated amount from the subform to directly populate a Bound Control.
(The subform contains a series of items on an invoice. The Main Form is the actual invoice, and I would like to record the total price of each of the item's costs onto a record associated with the Invoice.
I do not do code, and would like to know how I can do this using macros or just keying into a section of the Properties associated with the text Box.
Thanks for the anticipated help.
BigDaddrock
Jul 6 '10
29 2945
Bigdaddrock
67 New Member
@NeoPa
As much as I appreciate your assistance, I am disappointed to report that when I added the code, exactly as written above I still fail to get any change in the control "ShipTot". Note, that TotShipWt is a control in the subform entitled SubFormA. Does that have to be introduced in some way?
The reason I need to store this figure in the Table, is that if the shipping costs associated with the various weights change at a later date, I DO NOT want the values stored previously to change.
Thanks again for your continuing assistance.
Jul 14 '10 #11
NeoPa
32,584 Recognized Expert Moderator MVP
I'm assuming that :
  1. [TotShipWt] is a control on a form that is used as a subform for another form.
  2. [ShipTot] is a control on the other form.
The code is associated with [TotShipWt] and the code refers to [ShipTot] via Me.Parent, which is a pointer to the form that the current form is a subform of.

I would expect this to work. If you see nothing wrong with my assumptions yet the code fails to work you may attach a copy of your database to your next post and I'll look at it for you.

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 the process depends on any linked tables then make local copies in your database to replace the linked tables.
  4. If you've done anything in steps 1 to 3 then make sure that the problem you're experiencing is still evident in the updated version.
  5. Compile the database (From the Visual Basic Editor select Debug / Compile {Project Name}).
  6. Compact the database (Tools / Database Utilities / Compact and Repair Database...).
  7. Compress the database into a ZIP file.
  8. 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.
It's also a good idea to include some instructions that enable us to find the issue you'd like help with. Maybe some instructions of what to select, click on, enter etc that ensures we'll see what you see and have the same problems.
Jul 15 '10 #12
Bigdaddrock
67 New Member
Will comply, but am concerned you are making the issue more complicated than it is. I am only using a single form which contains the control ShipTot and the SubformA is included in that form. SubformA contains the control TotShipWt. I merely want to set the Value of ShipTot based on the latest value of TotShipWt.
Is that clear?
Jul 15 '10 #13
NeoPa
32,584 Recognized Expert Moderator MVP
I was rather hoping you'd confirm my stated assumption rather than trying to re-explain the situation.

From what I understand of your explanation, there is no difference between that and what I stated, but I'm the one who needs to check with you (who should know) that I understand what you're saying.

My confirming what you say matches what I'm thinking (which I'm happy to do) doesn't really get us very far as I don't have your problem.
Jul 15 '10 #14
patjones
931 Recognized Expert Contributor
I'm sorry to jump in at this point, but after looking at all the recent posts, I do think that either the two lines of code I provided previously, or the code that NeoPa provided, should function in this situation.

I wonder if the problem is much simpler than we have been making it. Is the parent form a bound form? I ask this because there is a set of properties in a form's property sheet that have a pretty big impact on what you're allowed to do in a bound form. Namely, they are Data Entry, Allow Additions, Allow Deletions, and Allow Edits.

The recordset type setting (Dynaset versus Snapshot) can also impact whether you are allowed to do what you are attempting.

I bring all this up only because we've had a couple questions recently on this forum where these settings played a role in solving the problem.

Pat
Jul 15 '10 #15
Bigdaddrock
67 New Member
@zepphead80
By all means, jump right in!!
Yes, the form is Bound, and Yes the settings for Data Entry, Allow Additions, Allow Deletions, and Allow Edits are all set to YES.
Jul 15 '10 #16
Bigdaddrock
67 New Member
@Bigdaddrock
I thought I did reply to your assumptions, which were not correct.
You stated:
I'm assuming that :

1. [TotShipWt] is a control on a form that is used as a subform for another form.
2. [ShipTot] is a control on the other form.

My answers are:
1. Wrong. [TotShipWt] is a control on the subform of the active form (not used as a subform on another form).
2. Wrong. [ShipTot] is a control on the active form.
Does that clarify things?
And more importantly, would that revise your solution? I hope so, since I am still seeking a solution.
Thanks for your patience and assistance.
Jul 15 '10 #17
NeoPa
32,584 Recognized Expert Moderator MVP
I think the confusion here comes from my use of the term "another form". I was intending this to mean other than the form already referred to in the text, rather than a form other than the active form. As such, we do seem to be agreeing. The active form, is referentially blank (it is undefined without context) so it could mean the subform to me (It would indeed as this is where the code is executing), but the main form to you.

I'm afraid that leaves us no further along I'm sorry to say :(

That said, I notice you say that .DataEntry is set to YES. When that is YES then .AllowDeletions and .AllowEdits are ignored and behave as if set to NO. .DataEntry is a special case for allowing only new data to be entered via a form.

I hope this leads in the right direction.
Jul 15 '10 #18
patjones
931 Recognized Expert Contributor
If you're willing to, post the file and I will take a look at it. Just strip it of any confidential data and follow the other suggestions in NeoPa's posting guidelines.

Sometimes we get into these length back-and-forth threads when the problem could've instead been diagnosed much more easily if it was right in front of us.

Pat
Jul 15 '10 #19
NeoPa
32,584 Recognized Expert Moderator MVP
Oh, and just in case I was a little unclear, you last post (#17) was perfect. It indicated clearly exactly where the confusion was. From there it was cleared (unfortunately didn't result in a ready solution but confusion gone).

I didn't want you to take my last post as criticism. It was just explanation.

PS. I'm also happy with Pat's suggestion. If it's easy for you to post a copy of the db then we can look at it for you. I expect the solution will be much easier with it in front of us :)
Jul 15 '10 #20

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

Similar topics

5
2398
by: Georges Heinesch | last post by:
Hi. Is it possible to put a tab control inside another tab control. I tried it several times, but for some reason this doesn't seem to work. Can someone confirm this, or tell me what the trick is. Thanks. --
5
27564
by: Paul Mendez | last post by:
I am creating a form with a tab control containing 10 tabs. and what I want to do is on only on of the tabs, I want a sub section of tabs. So what it ends up being is one main tab control with another tab control embedded into only one of the tab pages. The problem I am getting is when I insert the sub section tab control into one of the tabs from the main tab control, the sub section tab control appears in every tab in the main tab...
6
6679
by: Tom Rowton | last post by:
This one has me a bit confused and I'm not finding what I need in the MSDN or by searching these forums, so here goes... I have a rather large, complex code-in-page WebForm (don't ask) and a section of that Form is 4 or 5 ASP:Panels pretending to be a set of Tabs, each with its own section of the form.
3
7145
by: qwerty | last post by:
I have two User controls in a page. Them ID-propertys are example UC1 and UC2. In code behind file they are declared: Public UC1 As UC1 Public UC1 As UC1 From the page I can call them with their name (UC1 and UC2) and access their public propertys and functions.
1
1436
by: Jonah Olsson | last post by:
Hello, I'm trying to build an "add-on" to an already existing custom web user control. The old control collects some user data and saves it to a database. The new control should collect some extra info from the user and add it to a new table in the database. The old control should not be re-written (at least not now..), so I need a way of capturing the click event of the Save button in the old control. This event should trigger a...
2
1289
by: DJ | last post by:
Hi, I have a user control that produces and maintains a student form for test enrollment. It contains all functionality such as adding, editing, suspending, etc., a student from a selected test instance. The main page uses the student form control (above), plus a control that produces the button pad (for administrative functionality) and one that produces a student roster.
2
10107
by: kumarpappu | last post by:
hello - I am newbie in winforms and c#. i have a mainform.cs and it has 2 user controls - leftView and rightView. In leftView.cs i am instantiating a new clientLeftView(another user control) and also the clientRightView(another user control) Now clientLeftView has a lstClient - list box.
2
1562
by: reidarT | last post by:
I have 3 fields in an aspx page. The 3. field should be the sum of field A and field B I use OnTextChanged to calculate the sum in field3. At the same time I want to insert the content of theese 3 fields into a row in a table. The problem is that I need 'postback is true' on the textfields to get an immediate calculation and then the insert action is triggered. reidarT
4
1695
by: Michael R | last post by:
In a continous form, I need txbControl1 to be conditioned according to txbControl2. txbControl1 control source is: =DSum("Amount","Loans","Id=Forms!Cities!Customers.Form!Id") txbControl2 control source is of the subform's record source table So the condtional formatting of txbControl2 would be: txbControl1.value = 1000
2
1324
by: erobinso | last post by:
In IE it is simple to address form fields with the same name in multiple forms, such as: document.firstform.mode.value='open'; document.secondform.mode.value='new'; etc But in Firefox I am forced to use getElementById, as in: document.getElementById.value='open';
0
9802
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
9652
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10226
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9343
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...
1
7765
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6961
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
5631
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
4430
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
2
3990
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.