473,785 Members | 2,553 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Change event trigger

Hi,

I have two forms A and B, both opened. In form A, I programmaticall y
change the Date of Birth field of the current record of form B. I
noticed that form B automatically displays the new data correctly.
However, when I tried trapping the After Update, On Dirty, On Change,
and On Current events of the Date of Birth text box, none of them gets
triggered. I want to trap this change event so that in form B, I can
programmaticall y calculate the Age field based on the Date of Birth
field that was changed. Is there a way to handle this situation?

Thanks
Tony

Dec 31 '05 #1
1 3520
Per Tony:
I have two forms A and B, both opened. In form A, I programmaticall y
change the Date of Birth field of the current record of form B. I
noticed that form B automatically displays the new data correctly.
However, when I tried trapping the After Update, On Dirty, On Change,
and On Current events of the Date of Birth text box, none of them gets
triggered. I want to trap this change event so that in form B, I can
programmatical ly calculate the Age field based on the Date of Birth
field that was changed. Is there a way to handle this situation?


In MS Access, there often seems tb at least a half-dozen "right" ways to do
something.

Personally, I'd favor writing a function to compute a person's age and using
that. The function would be dirt simple, but at least the logic would be
encapsulated in one place.

Error trapping is another story. You're on your own there bc I do stuff with
writing to an error log that would just make the example get lost in the noise.

For calc-ing the age, let's just say:
------------------------------------------
Public Function AgeOfPersonInEv enYears(ByVal theBirthDate As Variant) As Variant

' PURPOSE: To compute the age of somebody in years (no months, no days, just
' years)
' ACCEPTS: The person's birthdate
' RETURNS: The Person's age or Null
'
' NOTES: 1) This thing started life as something tb called from a query that
' a form is based on. Because that situation can result in calls
' to this function whenever fields change on the form and there
' not be a BirthDate present all the time, we want to let things
' slide if no BirthDate is passed.
' 2) The form's built-in editing *should* prevent non-date values from
' getting to us, but we check anyhow in case the func is called from
' someplace else.

Dim myAge As Variant
Dim myDays As Long
Dim myToday As Variant

If Not IsNull(theBirth Date) Then
If Not IsDate(theBirth Date) Then
MsgBox theBirthDate, vbCritical, "Not A Date"
Else
myToday = Date
myDays = DateDiff("d", theBirthDate, myToday)
If myAge < 0 Then
MsgBox theBirthDate, vbCritical, "Date Must Be Before Today"
Else
myAge = DateDiff("yyyy" , theBirthDate, myToday)
End If
End If
End If

AgeOfPersonInEv enYears = myAge
End Function
-------------------------------------------

The above function is probably wretched excess and could be pruned to just a few
lines...but the idea is to wrap the calc in a single function.

Once the function is there, I'd base each form on the same query - something
like this:
-------------------------------------------
SELECT
tblPerson.*,
AgeOfPersonInEv enYears([BirthDate]) AS myAge
FROM tblPerson;
-------------------------------------------

Then in both frmA and frmB, we'd have a field named "txtAge" whose
..ControlSource =myAge.

Lastly, in frmA, we'd have:
-------------------------------------------
Private Sub txtBirthDate_Af terUpdate()
On Error Resume Next
Forms!frmB.Requ ery
End Sub
-------------------------------------------

Again, you're on your own for the error trapping.
The idea of On Error Resume Next is that the Sub won't bomb if frmA is not open.
--
PeteCresswell
Dec 31 '05 #2

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

Similar topics

2
9778
by: Nick Pritchard | last post by:
Well, there are a couple ways you could do that. You could write a windows service with a System.Timers.Timer object, that fires an event ever 15 minutes. Or, you could use a trigger on the table you are evaluating. On update for your table, your trigger fires executing a piece of code that could be a SQL job, or an actual executable you had written in VB or VB.net. The easiest programatic way would probably be the service though.
2
17518
by: R. Rajesh Jeba Anbiah | last post by:
I have Googled a lot, but couldn't still find the answer... I could see, I can trigger the "click" event like: button_object.Click() But, I need to trigger the onChange() of select options. I couldn't find anything like: select_object.Change() More specifically, I have something like:
2
5306
by: RWD | last post by:
I am trying to figure out how to change the target frame in my hyperlink on a DHTML menu. The menu is in one frame and the target frame is called "main" The code is below: Thanks in advance RWD <script type='text/javascript'>
1
3783
by: Jimmer | last post by:
How do you recognize a change in the value of a calculated control? The normal events such as Dirty don't seem to work, unless I physically interact with the control in some way. My problem is this, I have several contols which provide subtotals from 10 forms. When a value in one of these forms is changed, which updates the control value, I want it to requery a the record source of another (11th) subform. I've tried requerying the...
2
1385
by: Grey | last post by:
I have a dropdownlist control in ASP.NET form. But when I click on the control and attempt to change the option, there is nothing to happen to the server side, that is cannot trigger in action. How come of this happen??? Is it use "SelectedIndexChanged" for dealing the change options event?? Million thanks
3
6167
by: David | last post by:
Hi If I change the checked value of the checkbox by code, I can not trigger the CheckedChanged event of a checkbox control. Is there any way to implement it? Thank you very much!
8
2358
by: Steve Schroeder | last post by:
For some reason I cannot get the OnSelectedIndexChanged event to fire for a listbox I have on a page. I'm able to populate the listbox with data from a stored procedure, but cannot trigger the event. I do have EnableViewState = True for the listbox. I'm imagining (wanting) to populate the listbox named: lstNames by using the DataValueField from lstDepartments. It's quite apparent though that the event is not triggering as I can misname...
5
1592
by: Earl | last post by:
I want to fire a database update off of a single change to a single cell in the datagrid. This apparently cannot be done using keypress, keyup, keydown, etc. I've read George Shepard's FAQ and while I may have overlooked it, I have not found an answer. I now am using the CurrentCellChanged event, and this is satisfactory IF the user moves off of the cell before closing the form. An obvious alternative would be to check for changes before...
0
5013
by: Michel Lapointe | last post by:
Hello, I would like to know if there is an event for the Datagridview control that is trigger before the selection change and is cancelable. I'm currently using the SelectionChanged event (using Full Row Select), but this event is trigger only after the selection changed is completed and therefore is non cancelable unless you keep the previous selection in a variable and rechange the selection, which is painful.
5
6868
by: mabond | last post by:
Hi Can't believe I've not been able to find the answer to this in the on-line help. I have a CheckedListBox which, via a timer control, is populated with the names of files in a network folder. The "check mark" for each item in the control is determined by the boolean value of a custom property field of the file. That value is found using microsoft's dsofile.dll class.
0
10324
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
10147
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
10090
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
9949
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
6739
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
5380
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...
0
5511
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3645
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2879
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.