dbTalk Databases Forums  

Sub form events not firing

comp.databases.ms-access comp.databases.ms-access


Discuss Sub form events not firing in the comp.databases.ms-access forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Bobby
 
Posts: n/a

Default Sub form events not firing - 03-26-2009 , 02:19 AM






Hi folks,
I'm using Access 2007 as the front end and SQL server as the backend
of an application I have written. I am also using Windows XP.

I have a subform which holds employee time bookings for the day, held
as minutes. The idea is, when an employee is selected from the main
form, all of his / her bookings display in the subform.

However, I need to total these minutes to display in the subform
footer. I want the total minutes to display as hours and minutes, not
just a sum of minutes.

My basic problem is, I can't find an event on the subform which fires
when the sub form has been completely populated. On Open, On Activate,
non of them fire. Is there a way of making an event fire when the sub
form is populated with new data?

I have attempted two ways of getting round this. Firstly I have used
the sum function in a control source in the sub form footer as follows
=sum([mins]/60). As you might expect, this gives slightly odd results.
For example 2 hours 25 minutes is displayed as 2.42 hours.

My second method is to write a function which I also call from a
control source, i.e. =TSHoursAndMinutes(). I know that this works ok,
because if I put it on a button it gives exactly the right result,
i.e. 2 hours 25 minutes. However on the control source it always
returns 0 hours 0 minutes.

It's almost as if, unlike the sum function, my function runs before
the detail section gets populated.

Any ideas how I can get round this. It seems like it should be so
simple to me, yet it's causing me real problems.

Thanks for any help,

Colin


Reply With Quote
  #2  
Old   
Roger
 
Posts: n/a

Default Re: Sub form events not firing - 03-26-2009 , 03:43 AM






On Mar 26, 2:19*am, Bobby <bob... (AT) blueyonder (DOT) co.uk> wrote:
Quote:
Hi folks,
I'm using Access 2007 as the front end and SQL server as the backend
of an application I have written. I am also using Windows XP.

I have a subform which holds employee time bookings for the day, held
as minutes. The idea is, when an employee is selected from the main
form, all of his / her bookings display in the subform.

However, I need to total these minutes to display in the subform
footer. I want the total minutes to display as hours and minutes, not
just a sum of minutes.

My basic problem is, I can't find an event on the subform which fires
when the sub form has been completely populated. On Open, On Activate,
non of them fire. Is there a way of making an event fire when the sub
form is populated with new data?

I have attempted two ways of getting round this. Firstly I have used
the sum function in a control source in the sub form footer as follows
=sum([mins]/60). As you might expect, this gives slightly odd results.
For example 2 hours 25 minutes is displayed as 2.42 hours.

My second method is to write a function which I also call from a
control source, i.e. =TSHoursAndMinutes(). I know that this works ok,
because if I put it on a button it gives exactly the right result,
i.e. 2 hours 25 minutes. However on the control source it always
returns 0 hours 0 minutes.

It's almost as if, unlike the sum function, my function runs before
the detail section gets populated.

Any ideas how I can get round this. It seems like it should be so
simple to me, yet it's causing me real problems.

Thanks for any help,

Colin
in the footer, create a text box (invisible) called minutes, =sum(..)

create as 2nd visible text box, =cint(minutes / 60) & ":" & (minutes
mod 60)


Reply With Quote
  #3  
Old   
Bobby
 
Posts: n/a

Default Re: Sub form events not firing - 03-26-2009 , 06:22 AM



On 26 Mar, 09:43, Roger <lesperan... (AT) natpro (DOT) com> wrote:
Quote:
On Mar 26, 2:19�am, Bobby <bob... (AT) blueyonder (DOT) co.uk> wrote:



Hi folks,
I'm using Access 2007 as the front end and SQL server as the backend
of an application I have written. I am also using Windows XP.

I have a subform which holds employee time bookings for the day, held
as minutes. The idea is, when an employee is selected from the main
form, all of his / her bookings display in the subform.

However, I need to total these minutes to display in the subform
footer. I want the total minutes to display as hours and minutes, not
just a sum of minutes.

My basic problem is, I can't find an event on the subform which fires
when the sub form has been completely populated. On Open, On Activate,
non of them fire. Is there a way of making an event fire when the sub
form is populated with new data?

I have attempted two ways of getting round this. Firstly I have used
the sum function in a control source in the sub form footer as follows
=sum([mins]/60). As you might expect, this gives slightly odd results..
For example 2 hours 25 minutes is displayed as 2.42 hours.

My second method is to write a function which I also call from a
control source, i.e. =TSHoursAndMinutes(). I know that this works ok,
because if I put it on a button it gives exactly the right result,
i.e. 2 hours 25 minutes. However on the control source it always
returns 0 hours 0 minutes.

It's almost as if, unlike the sum function, my function runs before
the detail section gets populated.

Any ideas how I can get round this. It seems like it should be so
simple to me, yet it's causing me real problems.

Thanks for any help,

Colin

in the footer, create a text box (invisible) called minutes, =sum(..)

create as 2nd visible text box, =cint(minutes / 60) & ":" & (minutes
mod 60)- Hide quoted text -

- Show quoted text -
Thanks. I found it worked better with Fix rather than CInt, but thats
great,

Colin


Reply With Quote
  #4  
Old   
hans.updyke@gmail.com
 
Posts: n/a

Default Re: Sub form events not firing - 03-28-2009 , 09:53 AM



On Mar 26, 6:22*am, Bobby <bob... (AT) blueyonder (DOT) co.uk> wrote:
Quote:
On 26 Mar, 09:43, Roger <lesperan... (AT) natpro (DOT) com> wrote:

in the footer, create a text box (invisible) called minutes, =sum(..)

create as 2nd visible text box, =cint(minutes / 60) & ":" & (minutes
mod 60)

Thanks. I found it worked better with Fix rather than CInt, but thats
great,
The "/" operator performs floating point division, which you don't
need here. Instead, you can perform integer division using the "\"
operator.

CStr$(minutes \ 60) & ":" & (minutes mod 60)

Integer division will return an Integer type value if minutes is an
Integer, a Long if minutes is Long --- so there is no need to use Fix
or CInt to do a type conversion. As an added benefit, integer
division is significantly faster than floating point division.

I used the CStr function to explicitly convert the division result to
a string, but VBA will do the conversion for you if you don't want to
use CStr.

If minutes can ever be Null, you can use the Nz function to prevent
the expression from raising an error:

CStr$(Nz(minutes, 0) \ 60) & ":" & (minutes mod 60)

Good luck,
Hans


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.