473,394 Members | 1,852 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,394 software developers and data experts.

Function to lock form entry

5
gameDatetime comes from database
dateTimeNow of course is current time.

Question:

I want to be able to lock users from making changes, Friday to Sunday.

see once it is locked then all users can see other users data, but no one can change anything, not even individuals who entered the data, this is useful for printing all users data which is what I am trying to accomplish.

When it is not locked, then each user can only add/change their own data, this is perfect as well.

'--------------------------------------------------------------------------
' Returns true if all games for the specified week are locked.
'--------------------------------------------------------------------------
function AllGamesLocked(week)

dim dateTimeNow, rs, gameDatetime

AllGamesLocked = false

dateTimeNow = CurrentDateTime()
set rs = WeeklySchedule(week)
do while not rs.EOF
gameDatetime = CDate(rs.Fields("Date").Value & " " & rs.Fields("Time").Value)
if Weekday(gameDatetime) = vbSunday and gameDatetime <= dateTimeNow then
AllGamesLocked = true
exit function
end if
rs.MoveNext
loop

end function

'--------------------------------------------------------------------------
' Returns true if the game is locked, based on the specified start time.
'--------------------------------------------------------------------------
function GameLocked(gameDatetime)

GameLocked = false

if gameDatetime < CurrentDateTime() then
GameLocked = true
end if

end function
Sep 22 '07 #1
5 1778
Tawni
5
Must Be a Simple Way to like add 2 or minus 2 from "gameDatetime"

2 days before sunday is friday right?

but then will it screw up monday night football games ?

I should have mentioned this is for a football pool
Sep 22 '07 #2
jhardman
3,406 Expert 2GB
I might not understand, but this seems like a really simple problem, but I'm not sure I understand your question. What part is giving you trouble? If I was doing something like this, I would just hard-code the date requirement into the script:
Expand|Select|Wrap|Line Numbers
  1. if weekDay(date()) >=6 OR weekDay(date()) = 1 then
  2.    response.write "db is view-only until Monday"
  3. else
  4.    'give form for updating
  5. end if 
Jared
Sep 24 '07 #3
Tawni
5
Thanks for reply, I been searching site daily for replies or info to help.As well as try fix myself.

here is what i did recently and still no work (compare to above post code)

first off to explain better, this is a football pool.

right now for each week of play, user log in and enter their picks.
Each user cant see the other users picks when they go to the results page.
they only see "xxxxx" or their own picks, but once the Games are locked, then they can go back to the results page and print it out. SO lets say for simple explanation there is only Sunday games this week. Users might pick their picks on say Wed, and cant see other users picks until the pool is locked ( a deadline for picks to be in, cant make changes when pool locked).

I want to Lock the pool always on thur or say friday ( cause some weeks there is thur games) in which the current code will lock them out when game starts.

way code is now it works perfect with one exception, it allows picks to be changed up until start of the games, this is for security reason so no one keeps browser open after game start to cheat. It locks users out when game starts.

I want to keep that but add another lock where picks must be in no later then say friday.

Compare to above I was trying to lock as a test tuesday.



function AllGamesLocked(week)

dim dateTimeNow, rs, gameDatetime

AllGamesLocked = false

dateTimeNow = CurrentDateTime()
set rs = WeeklySchedule(week)
do while not rs.EOF
gameDatetime = CDate(rs.Fields("Date").Value & " " & rs.Fields("Time").Value)
if Weekday(gameDatetime) = vbSunday and gameDatetime <= dateTimeNow then
AllGamesLocked = true
exit function
end if
rs.MoveNext
loop

end function

'--------------------------------------------------------------------------
' Returns true if the game is locked, based on the specified start time.
'--------------------------------------------------------------------------
function GameLocked(weekday)

GameLocked = false

if weekday = vbTuesday then
GameLocked = true
end if

end function
Sep 26 '07 #4
Tawni
5
I might not understand, but this seems like a really simple problem, but I'm not sure I understand your question. What part is giving you trouble? If I was doing something like this, I would just hard-code the date requirement into the script:
Expand|Select|Wrap|Line Numbers
  1. if weekDay(date()) >=6 OR weekDay(date()) = 1 then
  2.    response.write "db is view-only until Monday"
  3. else
  4.    'give form for updating
  5. end if 
Jared
Jared thanks,

I will try that, one question though, since I get currentdatetime from server, then using your code, user cant trick it by changing their pc clocks right ?

if that is correct , I think I am more of a Noob then I thought at this, can't wait for my 6 books I ordered to arrive from amazon. That was such an easy fix, thanks a million. back to drawing board, I will post back let you know.
Sep 27 '07 #5
jhardman
3,406 Expert 2GB
Jared thanks,

I will try that, one question though, since I get currentdatetime from server, then using your code, user cant trick it by changing their pc clocks right ?

if that is correct , I think I am more of a Noob then I thought at this, can't wait for my 6 books I ordered to arrive from amazon. That was such an easy fix, thanks a million. back to drawing board, I will post back let you know.
date() and now() functions returns the date from the server, not from the user, so that isn't a problem.

My solution just kept the user from seeing the form if it was past the set date, but this could be tricked by users opening the page before the deadline, so you might need a more complicated solution. The same approach will work, but I'm not sure I've been all that helpful.

Jared
Sep 27 '07 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Tom Dauria | last post by:
I have a form that allows the user to select some number of People from a list. The user can select one or all of the people in the list. The list has thousands of names. Once the user makes...
0
by: eliffman | last post by:
I have an option group on my form that is used to toggle the form controls' Locked property. Somehow I'm also locking the "Unlock" option button (or the entire option group), but I'm not sure why....
2
by: 2D Rick | last post by:
When I filter a form by part number it returns 3 records. If I move to the third record and print it, the form returns to the first record. Can I force it to stay on the chosen record? Thanks,...
1
by: DoctorV3774 | last post by:
I need a function to do the following when opening a Form named NewFrm_MainTemplate. I need the function to look at the user id of the person attempting to open the form. Their Windows user ID...
6
by: Rosie | last post by:
Hi -- I have a main form attached to a table (Invoice header info). When the form loads I use acNewRec to take us to the end of a table, and I get a clean, empty form. The user, who knows...
6
by: alphaomega3 | last post by:
I'm back with a new set of problems with the old NCR database from a year ago. I have a form that is for Nonconformance Entry. In the process of entering this form if the supplier for the...
3
nirmalsingh
by: nirmalsingh | last post by:
hai all, How to call a function in Form, from a Class? using c#.net. thanx in advance Nirmal.
2
by: Tom | last post by:
Hi All I'd like to create a half decent looking form entry and search database for a few hundred DVDs. I've tried this myself and found doing it difficult so I'm just using a simple form for the...
5
by: John Boyd | last post by:
I know I can post to page 2 but the problem is I need to capture the name, email (optional), and referral source. If i post to page 2 then it simply asks for the required fields. If I do get it...
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: 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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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
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.