473,545 Members | 2,041 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Control Reference Question

I'm using Access 2000 and I have a main form and a subform. When a
control on the subform is updated I am trying to update a control on
the mainform. But instead of updating the control on the main form's
current record, it updates the main form's control on every record.

This is the code I'm using for this:
Set cnn = CurrentProject. Connection

strSQL = "SELECT SUM(AmountPaid) AS SumAmountPaid FROM BillPayments
WHERE " & _
"BillingInforma tionSK = " & Me.Parent!SK & " AND ProjectSK = "
& _
Me.Parent!cboPr ojectSK & ";"

rst.Open strSQL, cnn, adOpenDynamic, adLockOptimisti c

' Fill in values on main form
Me.Parent!Amoun tsPaid = rst!SumAmountPa id
Me.Parent!Balan ceDue = Nz(Me.Parent!Am ountsPaid) -
Nz(Me.Parent!Am ountBilled)

So my question is how can I make this code only modify the controls on
the current record in the main form?

Any help would be appreciated.

Nov 13 '05 #1
7 2048
Are AmountsPaid and BalanceDue bound controls? If not, then they will hold
the value you enter until you clear the value or otherwise change it. You
may want to do this in the Current event of the form so that it will change
when you move from one record to the next.

Is the main form in Continuous Form View or Datasheet View? Also, if the
controls aren't bound, you may want to use DSum to get a value for
AmountsPaid and just requery the control when you update the subform's
control. The DSum equation would go in AmountsPaid's Control Source. Since
BalanceDue is based on the value of two other controls on the main form, you
could also use a calculation in its Control Source that should update itself
automatically as the other two controls are updated. If not, issue a ReCalc
to the BalanceDue to force it to update.

--
Wayne Morgan
MS Access MVP
<vi*******@netz ero.com> wrote in message
news:11******** **************@ z14g2000cwz.goo glegroups.com.. .
I'm using Access 2000 and I have a main form and a subform. When a
control on the subform is updated I am trying to update a control on
the mainform. But instead of updating the control on the main form's
current record, it updates the main form's control on every record.

This is the code I'm using for this:
Set cnn = CurrentProject. Connection

strSQL = "SELECT SUM(AmountPaid) AS SumAmountPaid FROM BillPayments
WHERE " & _
"BillingInforma tionSK = " & Me.Parent!SK & " AND ProjectSK = "
& _
Me.Parent!cboPr ojectSK & ";"

rst.Open strSQL, cnn, adOpenDynamic, adLockOptimisti c

' Fill in values on main form
Me.Parent!Amoun tsPaid = rst!SumAmountPa id
Me.Parent!Balan ceDue = Nz(Me.Parent!Am ountsPaid) -
Nz(Me.Parent!Am ountBilled)

So my question is how can I make this code only modify the controls on
the current record in the main form?

Any help would be appreciated.

Nov 13 '05 #2
They are unbound controls. The main form is in Form view.

I know that if I put formulas in the controls that works. But I was
trying to get some code to run after updating these controls. And
being that they were using calculations and weren't bound I couldn't
get the code to fire.

So is there a way to get code to run on these unbound controls after
they are updated from the subform?

Thanks for the help.
"Wayne Morgan" <co************ *************** @hotmail.com> wrote in message news:<sG******* *********@newss vr30.news.prodi gy.com>...
Are AmountsPaid and BalanceDue bound controls? If not, then they will hold > the value you enter until you clear the
value or otherwise change it. You may want to do this in the Current event of the form so that it will change
when you move from one record to the next.

Is the main form in Continuous Form View or Datasheet View?

Also, if the controls aren't bound, you may want to use DSum to get a value for
AmountsPaid and just requery the control when you update the subform's
control. The DSum equation would go in AmountsPaid's Control Source. Since
BalanceDue is based on the value of two other controls on the main form, you
could also use a calculation in its Control Source that should update itself
automatically as the other two controls are updated. If not, issue a ReCalc
to the BalanceDue to force it to update.

--
Wayne Morgan
MS Access MVP
<vi*******@netz ero.com> wrote in message
news:11******** **************@ z14g2000cwz.goo glegroups.com.. .
I'm using Access 2000 and I have a main form and a subform. When a
control on the subform is updated I am trying to update a control on
the mainform. But instead of updating the control on the main form's
current record, it updates the main form's control on every record.

This is the code I'm using for this:
Set cnn = CurrentProject. Connection

strSQL = "SELECT SUM(AmountPaid) AS SumAmountPaid FROM BillPayments
WHERE " & _
"BillingInforma tionSK = " & Me.Parent!SK & " AND ProjectSK = "
& _
Me.Parent!cboPr ojectSK & ";"

rst.Open strSQL, cnn, adOpenDynamic, adLockOptimisti c

' Fill in values on main form
Me.Parent!Amoun tsPaid = rst!SumAmountPa id
Me.Parent!Balan ceDue = Nz(Me.Parent!Am ountsPaid) -
Nz(Me.Parent!Am ountBilled)

So my question is how can I make this code only modify the controls on
the current record in the main form?

Any help would be appreciated.

Nov 13 '05 #3
From the help file, "Changing data in a control by using Visual Basic or a
macro containing the SetValue action doesn't trigger these events for the
control. However, if you then move to another record or save the record, the
form's AfterUpdate event does occur."

So, this means that if you change the value of the control using code, the
AfterUpdate event for that control doesn't fire. However, you can place the
code you would have run in the AfterUpdate event in the code that changed
the value of the control or you can place the code in a procedure (including
the control's AfterUpdate event) that can be called from the code that
changed the value. If you use the AfterUpdate event for this code, you may
need to change its header line from "Private Sub" to "Public Sub". You
should the be able to call if from the subform as:

Me.Parent.NameO fControl_AfterU pdate
or
Forms!NameOfPar entForm!NameOfc ontrol_AfterUpd ate
--
Wayne Morgan
MS Access MVP
"Ecohouse" <vi*******@netz ero.com> wrote in message
news:dd******** *************** ***@posting.goo gle.com...
They are unbound controls. The main form is in Form view.

I know that if I put formulas in the controls that works. But I was
trying to get some code to run after updating these controls. And
being that they were using calculations and weren't bound I couldn't
get the code to fire.

So is there a way to get code to run on these unbound controls after
they are updated from the subform?

Nov 13 '05 #4
Wayne,

Thanks again for the help. What you wrote in your last post is what I
had wound up doing.

But going back to my original question about why all the controls in
the main form were updating when I did the following:

Me.Parent!Amoun tsPaid = rst!SumAmountPa id
Me.Parent!Balan ceDue = Nz(Me.Parent!Am ountsPaid) -
Nz(Me.Parent!Am ountBilled)

There is no way to reference a control on the main on a particular
record form from the subform?

Thanks again for the help.
"Wayne Morgan" <co************ *************** @hotmail.com> wrote in message news:<gb******* *********@newss vr11.news.prodi gy.com>...
From the help file, "Changing data in a control by using Visual Basic or a
macro containing the SetValue action doesn't trigger these events for the
control. However, if you then move to another record or save the record, the
form's AfterUpdate event does occur."

So, this means that if you change the value of the control using code, the
AfterUpdate event for that control doesn't fire. However, you can place the
code you would have run in the AfterUpdate event in the code that changed
the value of the control or you can place the code in a procedure (including
the control's AfterUpdate event) that can be called from the code that
changed the value. If you use the AfterUpdate event for this code, you may
need to change its header line from "Private Sub" to "Public Sub". You
should the be able to call if from the subform as:

Me.Parent.NameO fControl_AfterU pdate
or
Forms!NameOfPar entForm!NameOfc ontrol_AfterUpd ate
--
Wayne Morgan
MS Access MVP
"Ecohouse" <vi*******@netz ero.com> wrote in message
news:dd******** *************** ***@posting.goo gle.com...
They are unbound controls. The main form is in Form view.

I know that if I put formulas in the controls that works. But I was
trying to get some code to run after updating these controls. And
being that they were using calculations and weren't bound I couldn't
get the code to fire.

So is there a way to get code to run on these unbound controls after
they are updated from the subform?

Nov 13 '05 #5
This is what I ended up doing:

'Update the AmountsPaid field on the main form
strSQL = "UPDATE BillingInformat ion SET AmountsPaid = " &
rst!SumAmountPa id & " WHERE " & _
"SK = " & Me.BillingInfor mationSK & ";"

cnn.Execute strSQL

'Update the BalanceDue field on the main form
strSQL = "UPDATE BillingInformat ion SET BalanceDue = " & BalanceDue & "
WHERE " & _
"SK = " & Me.BillingInfor mationSK & ";"

cnn.Execute strSQL

This runs after a control on the subform updates. I know it's a bit
convoluted but it works.

Nov 13 '05 #6
An unbound control doesn't belong to any particular record (it isn't bound),
so when you set the value in the unbound control it is set of all records.
You have to take over the job Access does with bound controls and update it
yourself when you move from record to record.

--
Wayne Morgan
MS Access MVP
"Ecohouse" <vi*******@netz ero.com> wrote in message
news:dd******** *************** ***@posting.goo gle.com...
Wayne,

Thanks again for the help. What you wrote in your last post is what I
had wound up doing.

But going back to my original question about why all the controls in
the main form were updating when I did the following:

Me.Parent!Amoun tsPaid = rst!SumAmountPa id
Me.Parent!Balan ceDue = Nz(Me.Parent!Am ountsPaid) -
Nz(Me.Parent!Am ountBilled)

There is no way to reference a control on the main on a particular
record form from the subform?

Thanks again for the help.
"Wayne Morgan" <co************ *************** @hotmail.com> wrote in
message news:<gb******* *********@newss vr11.news.prodi gy.com>...
From the help file, "Changing data in a control by using Visual Basic or
a
macro containing the SetValue action doesn't trigger these events for the
control. However, if you then move to another record or save the record,
the
form's AfterUpdate event does occur."

So, this means that if you change the value of the control using code,
the
AfterUpdate event for that control doesn't fire. However, you can place
the
code you would have run in the AfterUpdate event in the code that changed
the value of the control or you can place the code in a procedure
(including
the control's AfterUpdate event) that can be called from the code that
changed the value. If you use the AfterUpdate event for this code, you
may
need to change its header line from "Private Sub" to "Public Sub". You
should the be able to call if from the subform as:

Me.Parent.NameO fControl_AfterU pdate
or
Forms!NameOfPar entForm!NameOfc ontrol_AfterUpd ate
--
Wayne Morgan
MS Access MVP
"Ecohouse" <vi*******@netz ero.com> wrote in message
news:dd******** *************** ***@posting.goo gle.com...
> They are unbound controls. The main form is in Form view.
>
> I know that if I put formulas in the controls that works. But I was
> trying to get some code to run after updating these controls. And
> being that they were using calculations and weren't bound I couldn't
> get the code to fire.
>
> So is there a way to get code to run on these unbound controls after
> they are updated from the subform?

Nov 13 '05 #7
Thanks again for all the help.

Nov 13 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
2917
by: ckerns | last post by:
I want to loop thru an array of controls,(39 of them...defaults = 0). If value is null or non-numeric I want to assign the value of "0". rowString = "L411" //conrol name if (isNaN(eval ("document.forms."+rowString+".value")) == true ) { //this alert works if the value is a letter,i.e,"a" alert("You have entered an non-numeric...
3
4161
by: Not Me | last post by:
Hi, Just trying to get my head around tab controls, is there anywhere which would describe the structure of how they work? I seem to be ok so far, being able to check which page I'm on etc... but I'm at a loss when trying to access controls inside the tabs. If I try to access the form directly (!...etc.) I get an error that the form...
7
3179
by: Samuel | last post by:
Hi, I am building a page that makes use of user control as a templating technique. The following is that I have in mind and it is actually working: Root/ -- login.aspx -- login.aspx.vb -- UC/ ----- Classic/
2
4904
by: Mike | last post by:
Hi, I am strugling with a simple problem which I can't seem to resolve. I have an asp.net page which contains a server-control (flytreeview, which is a kind of a tree to be exact). The tree is being updated by some other process through remoting. When the page loads, I init the tree, and in my browser I can see the initialized tree. The...
0
1261
by: tony | last post by:
Hello! I have one solution file that consist of three project. One project that build the exe file. One project that build a class library dll One project that build a windows control dll In the windows control c-tor is there a call to a method in the class libarary. So in the project referense settings for the windows control I have a
0
1251
by: Tony Johansson | last post by:
Hello! I have one solution file that consist of three project. One project that build the exe file. called A One project that build a user control dll called B One project that build a class library dll called C In the constructor for this user control is a call to a method in the class library. public (){
4
1726
by: glenn | last post by:
Hi folks, I am getting an error "Object reference not set to an instance of an object". It seems I have everything in place but something is obviously in err. If you could take a quick peak at my code segments and provide any insight in a reply, I would be eternally grateful. My table name is "rfi" and the field with a dropdownlist...
3
4544
by: vtashore | last post by:
I downloaded Steve Leban's RTF2 control and it works as advertised. Good news! After reading reference material on the RTF standard codes, I have been able to write update queries to universally change the font or font size directly in my table without having to edit the text natively in Leban's control. Also good news. I see that there...
5
3727
by: John Kotuby | last post by:
Hi all, This is my first time trying to creaet and use a custome Web Control in a Web Site project in ASP.NET 2.0 with VS 2005 and VB. I created the control in a separate Web Control Library project. The original code for that control was written in VS 2003 for .NET 1.1. I created a Web Project and pulled the VB module into the project. I...
19
4536
Frinavale
by: Frinavale | last post by:
I'm in the middle of implementing a custom Ajax enabled Server Control. At this point I need help finding the answer to an Ajax Framework question...here it goes: I have a Server Control that extends from a Panel and implements the IScriptControl interface: Public Class MyCustomControl Inherits Panel Implements IScriptControl ...
0
7408
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...
0
7815
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...
1
7433
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...
1
5340
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...
0
4949
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...
0
3458
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...
0
3444
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1891
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
0
712
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...

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.