473,394 Members | 1,759 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.

How to lock specific records based on selection of Month?

12
I have a database, which keep track of the hours employee worked.
The employee enter the hours monthly. The table is set to like,

Project/ Month/ Hour/

what i want to do is: I want to lock the record based on the month. if i make a form with a month combo box. ..I want all of the record to be locked except the record that has the month matching the selected month. so, when employee enter their hours, they can only edit or add record to the month i specified.

how can i do that? plese give me some advise. Thanks.
Jun 20 '08 #1
8 2937
n8kindt
221 100+
you are the one specifying the month right? not the employees? if so, how are u able to specify the month while keeping them from doing likewise? i'm confused about what the purpose of the combo box is. are you wanting them to be able to view the past months and edit only the current month?
Jun 21 '08 #2
missinglinq
3,532 Expert 2GB
I agree with n8kindt; you need to give us a more detailed explanation of what you're trying to do in order for us to help you.

Welcome to Bytes!

Linq ;0>
Jun 21 '08 #3
lulu123
12
Thanks for reply, guys.

The combo box is for the admin, and it will be on a different form. So, the admin could select the mont she want to lock/not lock from the combo box.

any suggestions?
Jun 24 '08 #4
lulu123
12
n8kindt , thanks.

yea, the idea is to let the employee view the past month only , and able to edit current month. However, the purpose of the combo box is for an admin, so, she/he could choose which month to lock/not lock.

thanks.


Re: How to lock specific records based on selection of Month?
--------------------------------------------------------------------------------

you are the one specifying the month right? not the employees? if so, how are u able to specify the month while keeping them from doing likewise? i'm confused about what the purpose of the combo box is. are you wanting them to be able to view the past months and edit only the current month?
Jun 24 '08 #5
n8kindt
221 100+
Thanks for reply, guys.

The combo box is for the admin, and it will be on a different form. So, the admin could select the mont she want to lock/not lock from the combo box.

any suggestions?
there are many ways to go about doing this. the easiest way i can think of would be to create a continuous form based on a query such as this:

Expand|Select|Wrap|Line Numbers
  1. SELECT tblTimeLog.*
  2. FROM tblTimeLog
  3. WHERE ((([tblTimeLog].[Year]*12+[tblTimeLog].[Month])=
  4. [forms]![form1].[AdminComboBoxYear]*12+[forms]![form1].[AdminComboBoxMonth]));
  5.  
and make sure the to have the combo box in the admin form (admincomboboxmonth) be bound to a number corresponding with the month 1 thru 12. for the year, make sure it is bound to a number in the 4 digit year format (eg: 2006). you're going to have to add a year field to your table but that won't be hard.

then make a subform out of the time log table, and place it in the main form's header or footer but lock the data so it can't be edited.

you will probably also want to include a docmd.requery command somewhere so the data the user just added/changed in the main form will show up in the subform.
Jun 24 '08 #6
n8kindt
221 100+
there are many ways to go about doing this. the easiest way i can think of would be to create a continuous form based on a query such as this:
(all one line)
Expand|Select|Wrap|Line Numbers
  1. SELECT tblTimeLog.*
  2. FROM tblTimeLog
  3. WHERE ((([tblTimeLog].[Year]*12+[tblTimeLog].[Month])=
  4. [forms]![form1].[AdminComboBoxYear]*12+[forms]![form1].[AdminComboBoxMonth]));
  5.  
and make sure the to have the combo box in the admin form (admincomboboxmonth) be bound to a number corresponding with the month 1 thru 12. for the year, make sure it is bound to a number in the 4 digit year format (eg: 2006). you're going to have to add a year field to your table but that won't be hard.

then make a subform out of the time log table, and place it in the main form's header or footer but lock the data so it can't be edited.

you will probably also want to include a docmd.requery command somewhere so the data the user just added/changed in the main form will show up in the subform.
sorry, the where statement for the month on the admin form AND the previous month should be like this:

(all one line)
Expand|Select|Wrap|Line Numbers
  1. WHERE (((Year([tblTimeLog].[Date])*12+DatePart("m",[tblTimeLog].[Date]))=
  2. [forms]![form1].[AdminComboBoxYear]*12+[forms]![form1].[AdminComboBoxMonth] Or (Year([tblTimeLog].[Date])*12+DatePart("m",[tblTimeLog].[Date]))=
  3. ([forms]![form1].[AdminComboBoxYear]*12+[forms]![form1].[AdminComboBoxMonth])-1));
  4.  
  5.  
  6.  
Jun 24 '08 #7
lulu123
12
thanks for you help , n8kindt
but , i dont' really quite understand....
in this way, does this filter out everything that was not selected...so , how could user view the month that wasn't selected by the admin

please hlep ..thanks...

sorry, the where statement for the month on the admin form AND the previous month should be like this:

(all one line)
Expand|Select|Wrap|Line Numbers
  1. WHERE (((Year([tblTimeLog].[Date])*12+DatePart("m",[tblTimeLog].[Date]))=
  2. [forms]![form1].[AdminComboBoxYear]*12+[forms]![form1].[AdminComboBoxMonth] Or (Year([tblTimeLog].[Date])*12+DatePart("m",[tblTimeLog].[Date]))=
  3. ([forms]![form1].[AdminComboBoxYear]*12+[forms]![form1].[AdminComboBoxMonth])-1));
  4.  
  5.  
  6.  
Jun 25 '08 #8
n8kindt
221 100+
sorry, i am going to amend my post here as i think it got confusing (i even confused myself when i read it lol). originally i had set up your form to have all months viewable, but when i saw you only wanted 2 months visible, i backtracked and made a goof. here is the entire post the way it should have read.


there are many ways to go about doing this. the easiest way i can think of would be to create a regular (you won't need a continuous form--just a regular one. my aplogies) form based on a query such as this:

Expand|Select|Wrap|Line Numbers
  1. SELECT tblTimeLog.*
  2. FROM tblTimeLog
  3. WHERE ((([tblTimeLog].[Year]*12+[tblTimeLog].[Month])=
  4. [forms]![form1].[AdminComboBoxYear]*12+[forms]![form1].[AdminComboBoxMonth]));
  5.  
this chooses only the month that is selected in your admin form combo box(es) so this is the part that the user will be editing.
and make sure the to have the combo box in the admin form (admincomboboxmonth) be bound to a number corresponding with the month 1 thru 12. for the year, make sure it is bound to a number in the 4 digit year format (eg: 2006). you're going to have to add a year field to your table but that won't be hard.

then make ANOTHER query such as this:


Expand|Select|Wrap|Line Numbers
  1. SELECT tblTimeLog.*
  2. FROM tblTimeLog
  3. WHERE (((Year([tblTimeLog].[Date])*12+DatePart("m",[tblTimeLog].[Date]))=
  4. [forms]![form1].[AdminComboBoxYear]*12+[forms]![form1].[AdminComboBoxMonth] Or (Year([tblTimeLog].[Date])*12+DatePart("m",[tblTimeLog].[Date]))=
  5. ([forms]![form1].[AdminComboBoxYear]*12+[forms]![form1].[AdminComboBoxMonth])-1));
  6.  
this will display the month selected and the previous month.
place this subform in the main form's header or footer but lock the data so it can't be edited.

you will probably also want to include a docmd.requery command somewhere so the data the user just added/changed in the main form will show up in the subform. alternatively, you could configure the where statement for the subform query so that it only shows the previous month. if u choose this option and need help doing this let me know.

ps - paste that code into a query by selecting SQL view. then replace the "tblTimeLog", "form1", "AdminComboBoxYear", and "AdminComboBoxMonth" parts to whatever the name your table, form, and combo box names are. not sure if u knew that or not
Jun 25 '08 #9

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

Similar topics

4
by: Richard Holliingsworth | last post by:
Hello: I have an Access 2K form I built from a SQL Server 7.0 view. I want to lock certain fields in the database from users so they can see them on the views and forms, but NOT be able to edit...
9
by: adi | last post by:
Hi all, Hope there is a quick fix for this: I am inserting data from one table to another on the same DB. The insert is pretty simple as in: insert into datatable(field1, field2, field3)...
14
by: Gary Nelson | last post by:
Anyone have any idea why this code does not work? FileOpen(1, "c:\JUNK\MYTEST.TXT", OpenMode.Binary, OpenAccess.ReadWrite, OpenShare.Shared) Dim X As Integer For X = 1 To 26 FilePut(1, Chr(X +...
8
by: Komandur Kannan | last post by:
We have a smart device application running on handhelds(Symbol MC9000G). The backend is Oracle and a middle tier web services development done in Vb.net. We use pessimistic Locking due to...
3
by: Cagey | last post by:
What I'm trying for: If this selection or if click on selection (highlighted line choice/ which ever selection change) w/in query's combo dropdown list box (on Switchboard), then Open in...
3
by: Cindy | last post by:
I'm trying to use the NEWID function in dynamic SQL and get an error message Incorrect syntax near the keyword 'ORDER'. Looks like I can't do an insert with an Order by clause. Here's the code:...
6
by: jmartmem | last post by:
Greetings, I have an Access 2002 continuous form called "Project Update Form" in which users can update project values presented in a series of combo boxes and text boxes. Three of the combo...
2
by: metaperl | last post by:
First a simple question: Is it allowed to provide a date range that has an illegal date. For instance SELECT * FROM tbl WHERE datex >= 2007-09-01 AND datex <= 2007-09-31 Now for my real...
1
WyvsEyeView
by: WyvsEyeView | last post by:
I have a dataset subform on which I want to lock a field for just two specific records. Each record has a type_id and a desc field. I want to test the value of the type_id field for the current...
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
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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.