PC Review


Reply
Thread Tools Rate Thread

Access 2003 - Date Insertion

 
 
=?Utf-8?B?QW5keQ==?=
Guest
Posts: n/a
 
      5th Sep 2006
I am building a acces tool to track sepsis infections. There are several
date variables. I don't know how to include a check box that would
automatically insert the registration date into all of the other date fields
if they are the same.

I also need help in calculating minuetues across 24 hour time period.

Thanks to anyone that can help!!!
--
Thanks,
Andy
 
Reply With Quote
 
 
 
 
=?Utf-8?B?S2VuIFNoZXJpZGFu?=
Guest
Posts: n/a
 
      5th Sep 2006
Andy:

Are all these dates fields in the same table or query to which the form is
bound? If so then you just need to assign the value of the registration date
to the others with a few line of code.

Dim varDate as Variant

varDate = Me.[RegistationDate]

Me.[SomeOtherDate] = varDate
Me.[YetAnotherDate] = varDate
' and so on

You can put this in the AfterUpdate event procedure of the RegistrationDate
control if you want the others to automatically be given the same date as
their defaults when the registration date is entered; or you can put it in
the Click event procedure of a button on the form. The former is probably
not a good idea as a user could enter the other date(s) first and then go
back to the registration date; this may be unlikely but its theoretically
possible in a form. If you do use the AfterUpdate event procedure you might
want to get user confirmation:

Const conMESSAGE = "Use this date for x, y and z dates?"
Dim varDate as Variant

varDate = Me.[RegistationDate]

If MsgBox(conMESSAGE, vbYesNo + vbQuestion, "Repeat date?" = vbYes Then
Me.[SomeOtherDate] = varDate
Me.[YetAnotherDate] = varDate
' and so on
End If

If you use a check box then you first have to see if the registration date
is already entered, and if so assign its date to the other controls. So the
code for the check box's AfterUpdate event procedure would be like this:

Dim varDate as Variant

varDate = Me.[RegistationDate]

If Not IsNull(vardate) Then
If Me.[YourCheckBoxName] Then
Me.[SomeOtherDate] = varDate
Me.[YetAnotherDate] = varDate
' and so on
Else
Me.[SomeOtherDate] = Null
Me.[YetAnotherDate] = Null
' and so on
End If
End If

This would assign the registration date to the other dates if one has been
entered; if no registration date has yet been entered it would clear any
values in the other dates by setting them to Null. The code for the
AfterUpdate event of the RegistrationDate would now assign the values if the
check box had been checked before any dates were entered:

Dim varDate as Variant

varDate = Me.[RegistationDate]

If Not IsNull(vardate) Then
If Me.[YourCheckBoxName] Then
Me.[SomeOtherDate] = varDate
Me.[YetAnotherDate] = varDate
' and so on
Else
Me.[SomeOtherDate] = Null
Me.[YetAnotherDate] = Null
' and so on
End If
End If

You'll see that this is the same as the check box's code. The duplication
could be avoided by putting the code in a function in the form's module and
calling the function as the event property of both controls, but it will work
the same either way. Modularising the code in a function is just more
elegant.

The check box must be unbound of course and you'll probably want to reset it
to False (unchecked) in the form's Current event procedure:

Me.YourCheckBoxName = False

As regards calculating in minutes take a look at the DateDiff and DateAdd
functions. These have an Interval argument, for which the setting for
minutes is "n" ("m" is used for months).

Ken Sheridan
Stafford, England

"Andy" wrote:

> I am building a acces tool to track sepsis infections. There are several
> date variables. I don't know how to include a check box that would
> automatically insert the registration date into all of the other date fields
> if they are the same.
>
> I also need help in calculating minuetues across 24 hour time period.
>
> Thanks to anyone that can help!!!
> --
> Thanks,
> Andy


 
Reply With Quote
 
John Vinson
Guest
Posts: n/a
 
      5th Sep 2006
On Tue, 5 Sep 2006 06:07:02 -0700, Andy <(E-Mail Removed)>
wrote:

>I am building a acces tool to track sepsis infections. There are several
>date variables. I don't know how to include a check box that would
>automatically insert the registration date into all of the other date fields
>if they are the same.


You could put code into the AfterUpdate event of the checkbox control
like:

Private Sub chkAllTimes_AfterUpdate()
If Me!chkAllTimes Then ' did the user check the box?
Me!txtThisTime = NZ(Me!txtThisTime, Me!txtRegistrationDate)
Me!txtThatTime = NZ(Me!txtThisTime, Me!txtRegistrationDate)
<etc>
End If
End Sub

The NZ() function ensures that only *blank* controls will be
overwritten; someone might have entered some data and then clicked the
checkbox.

>I also need help in calculating minuetues across 24 hour time period.


An Access date/time value is stored as a simple number - a count of
days and fractions of a day (times) since midnight, December 30, 1899.
As such it doesn't explicitly contain minutes and hours. If you have
two date/time values you can use the DateDiff() function to calculate
the minutes (or seconds, or years, or any other time unit) between
them:

DateDiff("n", [CheckIn], [CheckOut])

"n" means "miNutes"; "m" is "Months".


John W. Vinson[MVP]


 
Reply With Quote
 
=?Utf-8?B?QW5keQ==?=
Guest
Posts: n/a
 
      6th Sep 2006
THANK YOU SOO MUCH!!!!! I would be so limited if I didn't get help from this
discussion groups. I greatly appreciate you taking the time to help me!!!
--
Thanks,
Andy


"Ken Sheridan" wrote:

> Andy:
>
> Are all these dates fields in the same table or query to which the form is
> bound? If so then you just need to assign the value of the registration date
> to the others with a few line of code.
>
> Dim varDate as Variant
>
> varDate = Me.[RegistationDate]
>
> Me.[SomeOtherDate] = varDate
> Me.[YetAnotherDate] = varDate
> ' and so on
>
> You can put this in the AfterUpdate event procedure of the RegistrationDate
> control if you want the others to automatically be given the same date as
> their defaults when the registration date is entered; or you can put it in
> the Click event procedure of a button on the form. The former is probably
> not a good idea as a user could enter the other date(s) first and then go
> back to the registration date; this may be unlikely but its theoretically
> possible in a form. If you do use the AfterUpdate event procedure you might
> want to get user confirmation:
>
> Const conMESSAGE = "Use this date for x, y and z dates?"
> Dim varDate as Variant
>
> varDate = Me.[RegistationDate]
>
> If MsgBox(conMESSAGE, vbYesNo + vbQuestion, "Repeat date?" = vbYes Then
> Me.[SomeOtherDate] = varDate
> Me.[YetAnotherDate] = varDate
> ' and so on
> End If
>
> If you use a check box then you first have to see if the registration date
> is already entered, and if so assign its date to the other controls. So the
> code for the check box's AfterUpdate event procedure would be like this:
>
> Dim varDate as Variant
>
> varDate = Me.[RegistationDate]
>
> If Not IsNull(vardate) Then
> If Me.[YourCheckBoxName] Then
> Me.[SomeOtherDate] = varDate
> Me.[YetAnotherDate] = varDate
> ' and so on
> Else
> Me.[SomeOtherDate] = Null
> Me.[YetAnotherDate] = Null
> ' and so on
> End If
> End If
>
> This would assign the registration date to the other dates if one has been
> entered; if no registration date has yet been entered it would clear any
> values in the other dates by setting them to Null. The code for the
> AfterUpdate event of the RegistrationDate would now assign the values if the
> check box had been checked before any dates were entered:
>
> Dim varDate as Variant
>
> varDate = Me.[RegistationDate]
>
> If Not IsNull(vardate) Then
> If Me.[YourCheckBoxName] Then
> Me.[SomeOtherDate] = varDate
> Me.[YetAnotherDate] = varDate
> ' and so on
> Else
> Me.[SomeOtherDate] = Null
> Me.[YetAnotherDate] = Null
> ' and so on
> End If
> End If
>
> You'll see that this is the same as the check box's code. The duplication
> could be avoided by putting the code in a function in the form's module and
> calling the function as the event property of both controls, but it will work
> the same either way. Modularising the code in a function is just more
> elegant.
>
> The check box must be unbound of course and you'll probably want to reset it
> to False (unchecked) in the form's Current event procedure:
>
> Me.YourCheckBoxName = False
>
> As regards calculating in minutes take a look at the DateDiff and DateAdd
> functions. These have an Interval argument, for which the setting for
> minutes is "n" ("m" is used for months).
>
> Ken Sheridan
> Stafford, England
>
> "Andy" wrote:
>
> > I am building a acces tool to track sepsis infections. There are several
> > date variables. I don't know how to include a check box that would
> > automatically insert the registration date into all of the other date fields
> > if they are the same.
> >
> > I also need help in calculating minuetues across 24 hour time period.
> >
> > Thanks to anyone that can help!!!
> > --
> > Thanks,
> > Andy

>

 
Reply With Quote
 
=?Utf-8?B?QW5keQ==?=
Guest
Posts: n/a
 
      6th Sep 2006
Thank you as well!!! Again, I really appreciate the time people take to
answer questions on-line.


--
Thanks,
Andy


"John Vinson" wrote:

> On Tue, 5 Sep 2006 06:07:02 -0700, Andy <(E-Mail Removed)>
> wrote:
>
> >I am building a acces tool to track sepsis infections. There are several
> >date variables. I don't know how to include a check box that would
> >automatically insert the registration date into all of the other date fields
> >if they are the same.

>
> You could put code into the AfterUpdate event of the checkbox control
> like:
>
> Private Sub chkAllTimes_AfterUpdate()
> If Me!chkAllTimes Then ' did the user check the box?
> Me!txtThisTime = NZ(Me!txtThisTime, Me!txtRegistrationDate)
> Me!txtThatTime = NZ(Me!txtThisTime, Me!txtRegistrationDate)
> <etc>
> End If
> End Sub
>
> The NZ() function ensures that only *blank* controls will be
> overwritten; someone might have entered some data and then clicked the
> checkbox.
>
> >I also need help in calculating minuetues across 24 hour time period.

>
> An Access date/time value is stored as a simple number - a count of
> days and fractions of a day (times) since midnight, December 30, 1899.
> As such it doesn't explicitly contain minutes and hours. If you have
> two date/time values you can use the DateDiff() function to calculate
> the minutes (or seconds, or years, or any other time unit) between
> them:
>
> DateDiff("n", [CheckIn], [CheckOut])
>
> "n" means "miNutes"; "m" is "Months".
>
>
> John W. Vinson[MVP]
>
>
>

 
Reply With Quote
 
=?Utf-8?B?YWRuaXph?=
Guest
Posts: n/a
 
      8th Jan 2007
i need to make check box to be changed to date that i'm checked on the box.
did it's same ways with what you wrote
--
access for life


"Andy" wrote:

> Thank you as well!!! Again, I really appreciate the time people take to
> answer questions on-line.
>
>
> --
> Thanks,
> Andy
>
>
> "John Vinson" wrote:
>
> > On Tue, 5 Sep 2006 06:07:02 -0700, Andy <(E-Mail Removed)>
> > wrote:
> >
> > >I am building a acces tool to track sepsis infections. There are several
> > >date variables. I don't know how to include a check box that would
> > >automatically insert the registration date into all of the other date fields
> > >if they are the same.

> >
> > You could put code into the AfterUpdate event of the checkbox control
> > like:
> >
> > Private Sub chkAllTimes_AfterUpdate()
> > If Me!chkAllTimes Then ' did the user check the box?
> > Me!txtThisTime = NZ(Me!txtThisTime, Me!txtRegistrationDate)
> > Me!txtThatTime = NZ(Me!txtThisTime, Me!txtRegistrationDate)
> > <etc>
> > End If
> > End Sub
> >
> > The NZ() function ensures that only *blank* controls will be
> > overwritten; someone might have entered some data and then clicked the
> > checkbox.
> >
> > >I also need help in calculating minuetues across 24 hour time period.

> >
> > An Access date/time value is stored as a simple number - a count of
> > days and fractions of a day (times) since midnight, December 30, 1899.
> > As such it doesn't explicitly contain minutes and hours. If you have
> > two date/time values you can use the DateDiff() function to calculate
> > the minutes (or seconds, or years, or any other time unit) between
> > them:
> >
> > DateDiff("n", [CheckIn], [CheckOut])
> >
> > "n" means "miNutes"; "m" is "Months".
> >
> >
> > John W. Vinson[MVP]
> >
> >
> >

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
using access for email campaigns - automatic date sent insertion? =?Utf-8?B?THJvYmVydHM=?= Microsoft Access Getting Started 1 10th Sep 2007 04:54 PM
Date insertion. =?Utf-8?B?UGF1bA==?= Microsoft Word Document Management 1 9th Nov 2006 02:15 PM
Access 2003 .gif file insertion - animation won't work =?Utf-8?B?VmFsZXJpZQ==?= Microsoft Access 4 6th Dec 2005 07:23 PM
Access 2003 Object Insertion =?Utf-8?B?TGluZGE=?= Microsoft Access 0 2nd Dec 2005 11:38 AM
Please help with date insertion SM Microsoft Excel Discussion 2 24th Sep 2004 07:33 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 05:37 PM.