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

Automate Building a diary for each employee.

Hi Folks,

I would like someone to help me with a code.

I have a table "TblEmployees" and another Table "TblDiary"
Fields: "EmployeeID" "Employee", "iDate"

When i hit a command button, i want the code to enter the date in the TblDiary for each date between 1/4/Year(Date) to 31/3/Year(Date)+1, for each employee :)

Hope someone can help.

Thanks :)
May 19 '10 #1

✓ answered by Delerna

in the on click event for the command button

something like this is one way
Expand|Select|Wrap|Line Numbers
  1. Private Sub Command0_Click()
  2.    Dim fromdte As Date, todte As Date, sql As String, EmpID As Integer
  3.    EmpID = 1
  4.    fromdte = CDate("1/4/" & Year(Date))
  5.    todte = CDate("31/3/" & Year(Date) + 1)
  6.    DoCmd.SetWarnings False
  7.    While fromdte <= todte
  8.       sql = "insert into TblDiary values(" & EmpID & ",'" & fromdte & "')"
  9.       DoCmd.RunSQL sql
  10.       fromdte = fromdte + 1
  11.    Wend
  12.    DoCmd.SetWarnings True
  13. End Sub
  14.  

2 1211
Delerna
1,134 Expert 1GB
in the on click event for the command button

something like this is one way
Expand|Select|Wrap|Line Numbers
  1. Private Sub Command0_Click()
  2.    Dim fromdte As Date, todte As Date, sql As String, EmpID As Integer
  3.    EmpID = 1
  4.    fromdte = CDate("1/4/" & Year(Date))
  5.    todte = CDate("31/3/" & Year(Date) + 1)
  6.    DoCmd.SetWarnings False
  7.    While fromdte <= todte
  8.       sql = "insert into TblDiary values(" & EmpID & ",'" & fromdte & "')"
  9.       DoCmd.RunSQL sql
  10.       fromdte = fromdte + 1
  11.    Wend
  12.    DoCmd.SetWarnings True
  13. End Sub
  14.  
May 19 '10 #2
Thanks Mateee :)
May 19 '10 #3

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

Similar topics

2
by: RR | last post by:
I am wondering what tables and relationships I would have to have to keep track of one or several employees commissions per transaction. One tracsaction can have one or several employees work on...
1
by: chatmili | last post by:
I am very frustrated after searching for three days. My problem seems to be so hard that no one really had an answer for it. I have seen postings with similar problem but they were either ignored...
18
by: Bruno Baguette | last post by:
Hello, I have to design a table wich will store some action reports. Each report have an ID like this 1/2004, 2/2004, ... and each years, they restart to 1 (1/2004, 1/2005, 1/2006,...). So, I...
7
by: Deano | last post by:
What's the current thinking about generating your own internal id for each record in a table? In my case I would like to add a field, for internal use within the program, that uniquely tags each...
2
by: Akinyemi | last post by:
I am developing a Payroll Program. I would like the Startup Form of the Program to show an image/icon representing an employee with the actual name of an employee under it or by its side just like...
3
by: Akinyemi | last post by:
I am creating a database in MSAccess 2000 for my Payroll Program I am writing. I want to save an image representing an employee in the record of each employee. I then want to post the name of each...
1
by: simonyong | last post by:
hello, everyone Sorry for disturb.. im newbie to asp.net im trying to do a task that as below: In a SAME datagrid, it ll show all data when user key in key word in textbox... datagrid will...
2
by: JennDavila | last post by:
Hello, I am running into an issue with adding a form that displays a calendar to where the manager can click a day and it will attach itself to a tracking table. I am new to this and have been...
4
by: karthisargunan | last post by:
Hello, I am developing the project of "Employee Information System" using C language, In this project i want to add the mobile number for the each employee {Each Mobile number having 7...
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: 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
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?
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
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.