UtterAccess.com
X   Site Message
(Message will auto close in 2 seconds)

Welcome to UtterAccess! Please ( Login   or   Register )

Custom Search
 
   Reply to this topicStart new topic
> Date picker - first day is Saturday?, Any Version    
 
   
USMCdBA
post Nov 15 2017, 11:06 AM
Post#1



Posts: 158
Joined: 11-December 02
From: Charleston, SC


I had a similar requirement and have adapted this solution...(I know more than 10 years later), but being restless and always wanting to go 1 step farther the question I have now is:


Is there a way to modify a date picker such that the first day of the week is Saturday and whatever day is selected by the user, the date entered will be the Friday date of that week?


I am not sure where to look or how to look for this.

--------------------
KDP
Charleston, SC -- USA
Bless those who don't need everything immediately.
Go to the top of the page
 
doctor9
post Nov 15 2017, 11:23 AM
Post#2


UtterAccess Editor
Posts: 17,924
Joined: 29-March 05
From: Wisconsin


KDP,

To convert a selected date to the friday of that day's week, you could do this:

CODE
SelectedFriday = dteSelectedDate - Weekday(dteSelectedDate + 1, vbUseSystemDayOfWeek) + 7


This will return 11/3/2017 for a selected date from 10/28/2017 to 11/3/2017.

Hope this helps,

Dennis

--------------------
(;,;) Li'l Cthulu says: Please talk about what you're trying to do, as well as how you're doing it.
Changing your real table name to "Table1" and your real form name to "Form1" in your posts makes it more difficult to understand what's going on, not easier.
Guidelines for Posting Questions
Go to the top of the page
 
doctor9
post Nov 15 2017, 01:33 PM
Post#3


UtterAccess Editor
Posts: 17,924
Joined: 29-March 05
From: Wisconsin


Follow-up:

Well, I suppose I made that more complicated than I needed to. This does the same thing:

CODE
SelectedFriday = dteSelectedDate - Weekday(dteSelectedDate, vbSaturday) + 7


Hope this helps,

Dennis

--------------------
(;,;) Li'l Cthulu says: Please talk about what you're trying to do, as well as how you're doing it.
Changing your real table name to "Table1" and your real form name to "Form1" in your posts makes it more difficult to understand what's going on, not easier.
Guidelines for Posting Questions
Go to the top of the page
 
merlenicholson
post Nov 15 2017, 01:58 PM
Post#4



Posts: 506
Joined: 23-November 11
From: Tampa, Florida, USA - UTC -5:00


KDP, I'm thinking you're not asking for code to calculate that Friday date, you're looking for a date picker. If you are, I have one you can modify if you're willing to tackle the code. It's at
http://www.UtterAccess.com/forum/index.php...1983816&hl=
The primary feature of this date picker is that it's 100% in code, and setting the left column to Saturday and returning the Friday date is straightforward, but only if you have just Access 32-bit or the knowledge to convert the API calls to 64bit.

If you are OK with tackling the code and need some advice, send me a private email with your questions.

--------------------
Merle Nicholson
Ninety percent of all mental errors are in your head. - Yogi Berra -
Go to the top of the page
 
USMCdBA
post Nov 15 2017, 06:29 PM
Post#5



Posts: 158
Joined: 11-December 02
From: Charleston, SC


Thank You Dennis,
In the form query for the Friday Week Ending Date I entered Week Ending: DateAdd("d",7-Weekday([entryDTG],7),[entryDTG]) in the field Name line. When the user enters the the date worked date ( [entryDTG] ), I have code that moves the focus to the next user data entry field ( [EHW] ) .

EHW is the "hours worked" field and it is the subject of my next question I am searching for.

The boss wants hours entered "just like our timesheets -- in 1/4 hour increments ( .00 ; .25 ; .50 ; .75)". As an example, the user would enter 5.75 for 5 3/4 hours. Great. I am now sniffing out the solution to limit the entries to those four possible decimal portions while at the same time defaulting to .00 if the user simply enters a whole number with no decimal point. My original thought was a Mod Operator, but that throws a 'Divide By Zero' error. Still plugging away at it, but feel free to interject thoughts as you wish.


Thanks much!
KDP

--------------------
KDP
Charleston, SC -- USA
Bless those who don't need everything immediately.
Go to the top of the page
 
USMCdBA
post Nov 15 2017, 06:39 PM
Post#6



Posts: 158
Joined: 11-December 02
From: Charleston, SC


Thanks for the offer Merle, I am saddled( big_grin.gif ) with a 64-bit OS and Office 16. I was hoping to go the easy route and have a date picker that did the conversion at the hands of the user, BUT the way I have now is acceptable. If you see my response to Dennis (above) you can see my next stroke-point. Thanks again!
KDP...

--------------------
KDP
Charleston, SC -- USA
Bless those who don't need everything immediately.
Go to the top of the page
 
doctor9
post Nov 16 2017, 09:47 AM
Post#7


UtterAccess Editor
Posts: 17,924
Joined: 29-March 05
From: Wisconsin


USMCdBA,

> The boss wants hours entered "just like our timesheets -- in 1/4 hour increments ( .00 ; .25 ; .50 ; .75)". As an example, the user would enter 5.75 for 5 3/4 hours.

So... you want the user to actually enter a value with a space between the whole number and the (possible) fraction, which includes a slash... like literally "5 3/4" and that converts to 5.75 for the stored value? If THAT is the case, here's one thing you can try:

Make a table of choices with two columns; a Currency column that stores the numeric values like 5, 5.25, 5.5, 5.75, etc and a text column that lists the data entry values like "5", "5 1/4", "5 1/2", "5 3/4", "6", etc.. Set up a combobox using the Currency column as the first column and the text column as the second column, and set the first column width to 0 to hide it from the user. When the user selects "5 3/4" the combobox's actual value will be 5.75. Since the combobox's bound column will be column 1, it will store the numeric value from the first column. Sort the combobox choices by the numeric field, obviously and set Limit To List to True. The user can even type a value. As soon as they hit the "5" key, the combobox will jump to the section starting with "5".

Hope this helps,

Dennis

P.S. I've added "stroke-point" to my vocabulary today. Sounds kinda like British/Military.

--------------------
(;,;) Li'l Cthulu says: Please talk about what you're trying to do, as well as how you're doing it.
Changing your real table name to "Table1" and your real form name to "Form1" in your posts makes it more difficult to understand what's going on, not easier.
Guidelines for Posting Questions
Go to the top of the page
 
doctor9
post Nov 16 2017, 11:12 AM
Post#8


UtterAccess Editor
Posts: 17,924
Joined: 29-March 05
From: Wisconsin


USMCdBA,

Oops, looks like I read your request backwards.

What do you want to do if the user tries entering 5.15? Do you want to round it up to 5.25? Or tell the user that's an invalid entry?

If you want to tell them to try again, you could use a simpler version of my combobox suggestion with just one column, storing all of the possible values between 0 and the longest number of hours someone can log in one record. If you want to round, you could try an AfterUpdate event for the textbox:

CODE
    If Nz(Me.curHours, 0) / 4 <> Int(Nz(Me.curHours, 0) / 4) Then
        Me.curHours = Int(Me.curHours * 4) / 4
    End If

Hope this helps,

Dennis

--------------------
(;,;) Li'l Cthulu says: Please talk about what you're trying to do, as well as how you're doing it.
Changing your real table name to "Table1" and your real form name to "Form1" in your posts makes it more difficult to understand what's going on, not easier.
Guidelines for Posting Questions
Go to the top of the page
 
USMCdBA
post Nov 16 2017, 11:37 AM
Post#9



Posts: 158
Joined: 11-December 02
From: Charleston, SC


Thanks Dennis and sorry for the confusion: I was slightly unclear with the quarter hours thing. We enter our ours worked in 15 minute increments but using decimals, so a user can enter any whole number followed by .00 or .25 or .50 or .75 . If the user types in a number and exits the field, the default fractional portion of the number will be .00 .

I am using tool tips and validation text to notify the user (who should ALREADY know how to fill in their hours -- since we have an entire division of blue hairs emailing & calling threatening to with hold pay until it is done correctly)

The problem is limiting the decimal values to .00 or .25 or .50 or .75 . I think I said before that I was trying to go with [EHW] Mod(0.25) = 0 on the Data Validation line. That makes mathematical sense as the remainder of any valid entry when divided by .25 would be zero. However, at table level, we can't reference a non-existing entry which EHW is until it is a saved record. It SHOULD work at the input form level, but when tried, I get a divide-by-zero error --which makes no sense.

I know I don't want to round-up user entries and I am sure I don't want to hard code all the possible entries -- mostly because I expect these yutzes will start entering their work for the entire week on one line which could in theory be as high as 112 hours. That would make for a 448 element combo box -- not impossible, but tedious and probably very confusing for some.

I will continue onward until the L.E.Ds in my head fire up.
Best etc...
KDP

--------------------
KDP
Charleston, SC -- USA
Bless those who don't need everything immediately.
Go to the top of the page
 


Custom Search
RSSSearch   Top   Lo-Fi    14th December 2017 - 01:02 AM