473,395 Members | 1,418 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Passing a date value

I am fairly novice at VB and access in particular and I am having
problems trying store a date into database field.

This is the scenario I am faced with.

I want to when click on a pause button and store the current date time
in a pause time field then when it is then unclicked it is to add the
time that elapsed to a total pause time field and the reset the pause
time back to Null.

If anyone knows as to how to do this it will be much appreciated here
is the code that I am using at the moment.

Private Sub cmdPause_Click()
If cmdPause = -1 Then
'Record Current Time
dteStartPause = Now()
UpdatePunchClock (punchClock_Paused)

Else
'Get current time - recorded time
PauseTime = Nz(PauseTime, 0) + CalcHours(dteStartPause, Now())
RecalcHours

UpdatePunchClock (punchClock_Started)
End If

End Sub
Nov 13 '05 #1
1 1768
Flipmode wrote:
I am fairly novice at VB and access in particular and I am having
problems trying store a date into database field.

This is the scenario I am faced with.

I want to when click on a pause button and store the current date time
in a pause time field then when it is then unclicked it is to add the
time that elapsed to a total pause time field and the reset the pause
time back to Null.

If anyone knows as to how to do this it will be much appreciated here
is the code that I am using at the moment.

Private Sub cmdPause_Click()
If cmdPause = -1 Then
'Record Current Time
dteStartPause = Now()
UpdatePunchClock (punchClock_Paused)

Else
'Get current time - recorded time
PauseTime = Nz(PauseTime, 0) + CalcHours(dteStartPause, Now())
RecalcHours

UpdatePunchClock (punchClock_Started)
End If

End Sub


This may help. You can test this out by following what I did.

I created a new form. I added 2 text boxes
Name = PauseTime DefaultValue = 0
Name = HoldTime DefaultValue = 0

I dropped a Toggle button onto the form. It's name is Toggle1

I dropped a Command button onto the form. It's name is CommandElapsed.

Now copy the below code, from Option Compare to the last End Sub into
the code window of the form.

Option Compare Database
Option Explicit
Private Sub Toggle1_Click()
If Me.Toggle1 = -1 Then
'toggle pressed in
Me.HoldTime = Now()
Else
'toggle released

'store the time difference in seconds
Me.PauseTime = Me.PauseTime + DateDiff("s", Me.HoldTime, Now())

'reset the holder. You really don't need to do this as it gets
'overwritten each time the toggle is pressed in.
Me.HoldTime = 0
End If
End Sub

Private Sub CommandElapsed_Click()

Dim h As Long, m As Long, s As Long

h = Int(Me.PauseTime / 3600) 'hours
m = Int((Me.PauseTime - (h * 3600)) / 60) 'minutes
s = Me.PauseTime - ((h * 3600) + (m * 60)) 'seconds
MsgBox Format(h, "00") & ":" & Format(m, "00") & _
":" & Format(s, "00")

End Sub

When the Toggle1 is pressed in, it stores the current time to HoldTime.
When it is released, it adds the difference in time toggled to
PauseTime. It also resets the HoldTime to 0

When CommandElapsed is pressed, it displays the hours, minutes, and seconds

I recommend that the time in PauseTime to be stored in seconds. You can
then determine the number of hours, minutes, and seconds...as the
routine does in CommandElapsed_Click.
Nov 13 '05 #2

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

Similar topics

1
by: Kevin Lyons | last post by:
Hello, I am trying to get all of my form elements passed correctly from the following URL: http://www.dslextreme.com/users/kevinlyons/selectBoxes.html to the following URL:...
7
by: Harolds | last post by:
The code below worked in VS 2003 & dotnet framework 1.1 but now in VS 2005 the pmID is evaluated to "" instead of what the value is set to: .... xmlItems.Document = pmXML // Add the pmID...
7
by: Mike | last post by:
I have to pass a date from a form to a report query. I have written a query that works fine when I execute from SQL view, But I dont know how to pass a value from the form to this query. SELECT...
2
by: JWH035 | last post by:
I'm having a problem properly passing a datetime variable to SQL from C#. In the sqladapter's properties / SelectCommand / parameters when I hard code the Value to a date for selection purposes the...
2
by: Keith | last post by:
Good Afternoon, New to .Net. I am trying to pass date/time values to a MS Access query depending on what value is selected from a dropdown list box (January, February, etc). I have declared...
3
by: IntraRELY | last post by:
I have the following function, Notice how I am passing the dateInterval as a string. What is the correct way to pass "DateInterval.Year" as a variable to a function? TIA, Steve Wofford...
0
by: pranesh.nayak | last post by:
Hello Group, (tech: C#, VS2005) I'm facing a problem in passing Nullable<DateTimeto a webservice. Below is code in webservice wrapper (reference.cs) used set/get date. When i set date value...
6
by: djjohnst | last post by:
I am creating a program that will list program times for people who visit our website. Users can login create, edit, delete a program. These dump into a database. The ASP webpage then reads from...
4
by: RachH | last post by:
Is there a way to pass a value to a report via VBA so the value can then be displayed in the report as a concantenation with a string? I have a report that displays all pricings that have occured...
3
by: ToddFur | last post by:
I see several postings on this but I am still unable to figure out my problem. I can pass the values of my text field but not radio button (or even checkboxes). My PHP file <?php //declare...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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...
0
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...
0
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...

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.