Modules & VBA :: Initializing Date And Time Variables

Jul 1, 2014

I am writing a process for a hospital application in the UK

We have a concept of "Takes" which are periods to which patients coming into hospital are assigned to and thus the consultant (specialist) who looks after them.

They are fixed times between 0800-2000 (Day take) and 2000-0800 (+1) Night take.

I have written the following function to try and determine which take a patient should be assigned to based on the time now to power various queries to enable the end user to quickly see "today's day take" and "yesterday's take"

Testing it I seem to not be able to hit the right "Take times" in my output. I suspect it's a problem with the way I'm initiating my variables as Today 0800 and Today 2000

Code:
Function GetTakeStarttime()
Dim StartTime As Long
Dim EndTime As Long
Dim CurrentTime As Long
Dim YestStartTime As Long

[Code] .....

View Replies


ADVERTISEMENT

Counting Date And Time With Variables

Feb 20, 2007

I am currently running a query which shows a date and time for several products:

Product 1 Product 2 Product 3 Product 4
01/01/07 12:00 01/01/07 15:25 01/01/07 15:25 01/01/07 17:36


From this information I need to count each Product unless the date & time is equal or within 30 minutes.

Any help on this one would be greatly appreciated.

View 2 Replies View Related

Modules & VBA :: Creating And Initializing Custom Class / Object

Jun 13, 2013

I've been playing around with creating my own class in VBA but I'm having problems calling its methods. My class is pretty basic, its called cDentist and the properties are just Name, Address, DOB etc and one method AddDentist. AddDentist will add the details to a sql server table.

So I create an instance of the class in a module called Dentist. At the very top of the code i put..

Code:
Option Compare Database
Global Dentist As cDentist

I have a method then in module Dentist, where I initialise the instance of class cDentist and i populate it's properities...

Code:
Sub RecordDentistDetails()
Set Dentist = New cDentist
Dentist.Name = Forms!frm_enterdetails!txtName

[Code].....

When I click 'Save' I get error, Method or data member not found. And '.AddDentist' is highlighted. I'm a little confused why it's not seeing AddDentist as a method of class cDentist.

View 14 Replies View Related

Modules & VBA :: Dcount With Date Variables

Jul 11, 2015

Im a relative novice with access VBA, and I'm really struggling with using Dcount with date variable. All I want to do is count if a certain date appears in a table. Here is the extract from my code:

Dim WorkoutDate as Date
Dim datecount as integer

datecount = DCount("[WorkOut Date]", "tblworkoutlogs", "[workout date]= " & WorkoutDate)

Whatever dates are in tblworkoutlogs, datecount is still = 0...I've trawled the net and tried many variations of the code but no success!if I change all the date formats to strings in the code and the tables, it works so I know i'm looking in the correct place.

View 5 Replies View Related

Modules & VBA :: Public Function With Variables Referencing Table Date Fields

May 31, 2014

I have a table with only two fields and one record: BegDate and EndDate (beginning and end date of the reporting period respectively). I also made a function with variables that look up those values for use as a date parameter in a query.

Here is the code:

Option Compare Database
Option Explicit
Public Function getCurrentRepDates() As Date
Dim dtBegDate As Date
dtBegDate = DLookup("BegDate", "tblCurrentRepDates")

[Code] ....

I am getting a syntax error for the line marked red. How can I use "Between" function in VBA code? Access 2010

View 5 Replies View Related

Working With Time Variables

Feb 21, 2008

I need to have my form give he user a Start time and then an End Time.

How do I store the variables (stirng, integer?)

How do I subtract the End Time from the Start Time to get a total time??

I then need to Multiple the resulting time frame by a Rate to calculate total value...

Any thoughts?

THanks

View 3 Replies View Related

Modules & VBA :: Set Datatype As Date / Time In The Form - Update Table With Null Date

Mar 12, 2014

I have a form with Date of Death (DOD) field. I would like update DOD from a table dbo_patient into Z_Patients table.

I have set the datatype as Date/Time in the form for Date of Death.

Code:
Private Sub Update_DOD()
Dim rcMain As New ADODB.Recordset, rcLocalDOD As New ADODB.Recordset
Dim DOD As String
rcMain.Open "select distinct PatientKey from Z_Patients", CurrentProject.Connection

[Code] ....

However I am getting some error Run-time error '-2147217913 Date type mismatch in criteria expression in section below.

Code:
CurrentProject.Connection.Execute "update Z_MAIN_Processed_Patients set DateOfDeath = '" & rcLocalDOD!date_of_death & "' where PatientKey = " & !PatientKey

View 5 Replies View Related

Hard Code TIME To Selected Date On Form (to Make It Date&time) For My Query Criteria

Aug 17, 2006

Hello buddies :D, do you have any idea how to make this work?

To select data that falls within this criteria of date range between cboDate and cboDate2 (fields on my form). The date in [tblJobDetails]![timeIn] come in this format "08/17/06 10:24 AM", but the cboDate/cboDate2 (takes in date only e.g 08/17/06) what i am after is to evaluate specific hard coded time in addition to the date entered, i.e. even tho, i haven't entered time on the cboDate/cboDate2, I want specific time hard coded where e.g If i select a date range of 08/17/06 and 08/18/06 on my cboDate and cboDate2 it should really be evaluating: 08/17/06 8:00 AM to 08/18/06 8:00 AM.

This is the criteria i curentlly have on my query in design view tha works perfect in selecting date only.
([tblJobDetails]![timeIn]>=[Forms]![frmPendingJobs]![cboDate] Or [tblJobDetails]![timeIn]>=[Forms]![frmPendingJobs]![cboDate] Is Null) And ([tblJobDetails]![timeIn]<=[Forms]![frmPendingJobs]![cboDate2] Or [tblJobDetails]![timeIn]<=[Forms]![frmPendingJobs]![cboDate2] Is Null)
How can I incorporate 8:00am to 8:00am into my cboDate and cboDate2. What can i do to make this happen? Your kindness will be greatly appreciated http://www.naijaryders.com/forums/images/smilies/thankyou.gif

View 10 Replies View Related

Modules & VBA :: SQL Date / Time Identifier?

Mar 3, 2015

i am having an issue with sql in vba using a variable for a date time field.

i know you identify date variables with #
i know you identify text variables with '

But now i have a date time field that is set to date but when i run the sql it does not find a match. i have confirmed that both rec and ercd match.

Also, when i change the table to text, i am able to match with single quote but i would like to keep the table as date if i can.

Below is the sql statement in question

isql = "SELECT * FROM Table1 WHERE from = '" & nm & "' AND rec = #" & ercd & "# AND sub = '" & esub & "'"

View 5 Replies View Related

Modules & VBA :: Current Time And Date On Msgbox?

May 4, 2014

How can i display current time and date on msgbox. in ms access 2007.

View 2 Replies View Related

Modules & VBA :: Save NOW (Date And Time) Into Event Log File

Oct 16, 2014

I want to save NOW() (i.e. Date and time) into an event log file. But I just cannot work out the syntax. My insert statement works fine without the date field in, but fails on a syntax error (3134) when I include it.

strsqlac = "INSERT INTO EventLog ( EventTime, User, EventType, EventMessage, DocRef, AutoSeq, CoCode ) " & _
" Values ( '" & Now() & "', '" & GlobUser & _
"', '" & Mess2 & _
"', '" & Mess1 & _
"', '" & Docref & _
"', " & AutoSeq & _
", '" & CoCode & _
"' );"

... it's the first column, EventTime that is the issue. I have tried several different ways of wrapping it in the VALUES () without success.

My database field EventTime is defined as a General date which Access 2007 tells me will give me date and time. That's what I want.

The Value formats I have tried (currently showing as 'NOW()' above, are ...

#NOW()#
#'NOW()'=
'#NOW()#'
and (as I say) 'NOW()'

View 5 Replies View Related

Modules & VBA :: Date And Time Functions Not Using Current Info

Jun 30, 2014

Encountered a situation where the Date and Time functions in VBA are not using current data? I have VBA code that uses Time to determine certain actions. A new associate took a copy of that code and started tinkering with it to complete a project I assigned. Now, his copy of the code returns old data for the Date and Time functions. It returns 5/27/2014 for Date and 7:15:42 AM for Time. The Now function works properly.

Additionally, running the Date and Time functions in queries works fine. I've compacted and repaired the Access database, I've checked the references, and I've checked to see if he assigned values to variables named Date or Time, but I don't see anything wrong. What am I missing?

View 14 Replies View Related

Modules & VBA :: Prevent For Duplicate Data (Time / Date)

Jul 26, 2014

I've a Sub form as datasheet view/grid.

See Capture1 & Capture2.

I'd like to prevent for duplicate time/date for same GuideCode. How can i prevent for those during the entry time or save time ? Is it possible ?

Capture1.

Capture2.

1. AUNKZ(GuideCode) is already assigned in other file number(12345) for 03-Aug-14 (as 02-Aug-14 to 04-Aug-14).

2. TOD(GuideCode) is already assigned in same file number(23456) for 10-Aug-14, 12:00 PM (as 10-Aug-14 to 10-Aug-14, 8:00AM to 1:00PM). I'd like to prevent if the file number are same or not same.

View 14 Replies View Related

Payment Date With To Many Variables?

Aug 2, 2007

Hi

We have a special reduced rate that a client must prepay 12weeks before or sooner if a date is put in the [OverRideDate] field

I have been trying to construct a Query / If statement or should I use case statement to work out the actual payment date. Taking in to consideration all our funny little variables like

I will try to put the variable into words

[DateOfArrival]-84Days unless [OverRideDate] & Not Less than today
then check its not a [ClosedDates] from the tbl_ClosedDates
Then if it’s a Sunday –1 day as the accounts lady doesn’t work on a Sunday

Their simple????

Attached file with sample variable data
BalanceDate.mdb

Ta
FAB1

View 1 Replies View Related

Queries :: Getting Date / Time Range - Date And Time Are Separate Fields

Mar 13, 2014

I have a database with date and time each stored in a separate field. Now I want to query the database based on a start date/time and an end date/time. I started with the code below but it only returns events within the same time range on each day when what I really need is every event from a specified date and time through a specified date and time.

SELECT myTable.ID AS myTable_ID, myDate, myTime, FirstName, LastName
FROM Staff INNER JOIN myTable ON
Staff.ID = myTable.StaffID
WHERE myTable.myDate >= #3/2/2014#
AND myTable.myDate <= #3/3/2014#
AND myTable.myTime >= #8:00PM#
AND myTable.myTime <= #11:00PM#
ORDER BY myDate desc

In the above example what I want is every event from 3/2/2014 8:00PM until 3/3/2014 11:00PM. But what I get instead is every event between 8:00PM and 11:00PM on 3/2/2014 and every event between 8:00PM and 11:00PM on 3/3/2014.

View 4 Replies View Related

Modules & VBA :: Append Time Value To A Date Data Type Variable

Jun 27, 2013

I have a variable (dtDueDate as Date) showing as 6/28/2013. I want to append a time value to it (dtMaxTime as Date) which is 5:00 PM so dtDueDate reads 6/28/2013 05:00:00 PM. I have been going in circles trying to figure this out. My goal is to append this date to a table field which has a datetime (General Date).

View 6 Replies View Related

Modules & VBA :: Change System Date / Time Without Admin Privileges

Mar 31, 2014

I have an Access 2010 application running on Win 7 Pro which connects to a Back End SQL Server database. I am trying to get Access to synchronise the client pc system date & time with the Sql server date and time. Please note, the date/time does not necessarily have to be correct, it just has to be consistent between the server and all the pcs running the Access application.

I have tried two methods as follows. But both only work if Access with Administrator privileges, which isn't really practical.

Method 1:

Code:
Dim MyDateTime As Date
'Some Code here to get MyDateTime
If MsgBox("Change date & time to:" & vbCrLf & vbCrLf & MyDateTime & "?", vbYesNo, "Change") = vbYes Then
Date = DateValue(MyDateTime)
Time = TimeValue(MyDateTime)
End If

Method 2:

Code:
Private Type SYSTEMTIME
wYear As Integer
wMonth As Integer
wDayOfWeek As Integer
wDay As Integer

[Code] .....

View 2 Replies View Related

Using Date Variables From Table In Query

Dec 22, 2011

I have a table that contains dates (Saturday through Friday). When I set up my query, I would like data returned where the date in a field is between the Saturday date and Friday date. Is there anyway to do this n the query without hard coding the dates in and manually changing the dates every week?

View 1 Replies View Related

Modules & VBA :: Default Property For Control Bounded To Date / Time Field

Dec 4, 2013

Access 2007

In a table I have 2 fields:

D1 , Date/Time , DefaultValue: Date()
D2 , Date/Time , DefaultValue: Date()+1

In a form (bounded to this table) I have, of course, 2 controls bounded to this fields:

txtD1 and txtD2

If the user change the value in txtD1 (using the Date picker) I like to change the DefaultValue for txtD1 to the new date and the DefaultValue for txtD2 to the new date + 1 day. Something like this:

Code:
Private Sub txtD1_AfterUpdate()
Me.txtD1.DefaultValue = Me.txtD1
Me.txtD2.DefaultValue = Me.txtD1 + 1 day
End Sub

I tried whatever crossed my mind... with the same "result" : #Name?

My Regional settings:

Short date format: dd.MM.yyyy
Date separator: Dot
Simple: 05.12.2013

View 14 Replies View Related

Modules & VBA :: Unable To Add Current Date And Time Into Separate Fields After ID Entered

Jul 26, 2014

I am trying to add the current date and time into separate fields after an ID is entered.

Code:
Option Compare Database
Private Sub ID_AfterUpdate()
Me.Date_Received = Date()
Me.Time_Received = Format(Now(), "hh:mm AMPM")
End Sub

View 5 Replies View Related

Modules & VBA :: SQL Server - Conversion Failed When Converting Date And / Or Time From Character String

Feb 13, 2014

I have two table

1. dbo.period (OpeningDate, ClosingDate)
2. dbo.data (blah blah, doc_date)

I want to create a view as follows

Select doc_date from dbo.data
where doc_date> 'select OpeningDate from dbo.period'

both doc_date and opening date have the same format

but the error will still appear as follows:
"Conversion failed when converting date and / or time from character string."

View 3 Replies View Related

Reports :: Report With Date Select / Search And Other Variables

Sep 26, 2014

I have a report reporting events that occurred today, using =Date() in the query.I want to have a control/box on the report which shows today's date by default, but enables me to select a different date with the outcome that the report refreshes and shows the events on the selected date instead.

Maybe I need a form for this although I would like to do conditional formatting so a report is better.It would also be good to be able to sort by column values, as in a table on a webpage with sort controls in the column headings which work just by clicking.

View 2 Replies View Related

Modules & VBA :: Passing Variables To A Sub Routine

Jan 13, 2014

I have a public sub routine which requires parameters to be passed to it when I call it from an access form. When I try to enter the code to call the sub I get a compile error. I've also tried calling it from another sub in the same module but get the same compile error - see below.

Code:
Sub EmailData(Datafile As String, To_mail As String, CC_mail As String, Subject_mail As String)
'code to use variables passed in
End Sub

[Code]....

View 4 Replies View Related

Modules & VBA :: Converting String To Variables?

Jan 30, 2015

I am trying to set up some template emails using text someone has entered in a form with a variable indicated with a key word in brackets aka. [ChangeID] or [ChangeDate]. The field on the form is formatted as Rich Text so I am getting http code. (No problems yet) In the form the template is required, I lookup the template required and I get the string. I replace the brackets with the following

Code:
strleftB = Chr(34) & " & me."
strRightB = " & " & Chr(34)
strTemplate = Replace(strTemplate, "[", strleftB)

I then get a string but in need to convert part of the string into variables, before I capture the correct output for my email

Code:
"<div>RFC Submission: <strong>" & me.ChangeID & ", </strong> " & me.Details & "</div>"

My question is: what is the best way to split the string into strings and variables

View 7 Replies View Related

Modules & VBA :: Possible To Initialize A Function Like Do For Variables?

Jul 15, 2015

Sometimes we need a one-line function to just get the database path or things like that we cannot do on a query or on a Macro Object.

Like:

Function GetDatabasePath() = currentproject.path

possible?

View 5 Replies View Related

Modules & VBA :: Assigning Index To Variables

Sep 11, 2014

How can I assign some type of index to the below variables (data representation) ? I'm using VBA to build a .RFT file for MS Word.

"Line # 1 data"
"Line #2 data"
"Line #3 data"

. . . .

"Line #7 data"
"Line #8 data"
"Line #9"

. . . .

"Line # 22 data"
"Line #23 data"
"Line #24 data"

View 14 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved