473,748 Members | 2,471 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

New Record every Friday morning

I have table that has the following fields:

JobNumber
WeekEndingDate
ReportRequired_ 01
ReportRequired_ 02

every Friday morning the weekending date changes. I need to
automatically generate a new record for each record that has a job
number and weekending date for the new weekending date.

i.e. JobNumber = 12345, WeekEndingDate = "4/12/2007",
ReportRequired_ 01 = yes, ReportRequired_ 02 = yes

This Friday, 4/20/2007, at 12am I would need to generate a duplicate
record for all jobs that have a weekending record of 4/12/07 and grab
the settings of reportRequired fields of the previous week. I have
total visual agent that I can use to automate the query or macro but I
am not sure how i would setup that query.

Thanks

Apr 17 '07 #1
1 2193
Hi Matt,

So ... this PC is left on and the database is open 24 / 7 / 365?
Assuming that this IS the case ... here are some thoughts:
Use a form timer event to test the Weekday value of Now() so that when 12:01
AM rolls around
and the Weekday evaluates to "6" (Friday) ... both conditions met ...
the following code should run and duplicate all records from the following
week.

Here is the form's code (Tested and appears to be working correctly ...You
may wish to add error handling.)
=============== =============== =============== =====
Option Compare Database
Option Explicit
' This variable is "in scope" as long as this form remains open, and is
False by default.
' So, if this form is closed and then re-opened (on a Friday only), the
duplication will occur again.
' You could prevent that from happening by declaring it as a Public variable
in a database module.
Dim blnCodeRun As Boolean
Private Sub Form_Timer()
'Timer interval is 6,000 milliseconds (60 seconds)
Dim vCurrDay
Dim vCurrDate As Date
Dim vLastFriday As Date
Dim strFind As String
Dim x
Dim Msg As String
vCurrDay = WeekDay(Now)
vCurrDate = Date

Select Case vCurrDay

Case 7 'Saturday
blnCodeRun = False 'This will remain False until the next Friday,
when the code runs again.

Case 6 'Friday (Set to current day if you want to test this eg 3 =
Tuesday)
'This code should run ONCE every Friday at 12:01 AM
If blnCodeRun = False Then

Dim rst As DAO.Recordset
Set rst = Me.Form.Records etClone

vLastFriday = DateAdd("d", -7, Date)

With rst
.MoveLast
.MoveFirst
strFind = "WeekEnding Date = " & "#" & vLastFriday & "#"
.FindFirst strFind

If .NoMatch Then
MsgBox "No details exist for Friday, " & vLastFriday
Else
Do Until .NoMatch

Dim vPrevJob
vPrevJob = !JobNumber
Dim PrevRpt01
PrevRpt01 = !ReportRequired _01
Dim PrevRpt02
PrevRpt02 = !ReportRequired _02

.AddNew
x = x + 1 'get a count of the number of records added
!WeekEndingDate = Date
!JobNumber = vPrevJob
!ReportRequired _01 = PrevRpt01
!ReportRequired _02 = PrevRpt02
.Update

.FindNext strFind
Loop

Msg = ""
Msg = x & " records from Friday, " & vLastFriday
Msg = Msg & " have been succesfully duplicated."
MsgBox Msg
blnCodeRun = True
Me.Bookmark = .LastModified
'This makes the last record visible in the form after
completion.
.Close
Set rst = Nothing
End If
End With
End If

End Select

End Sub
"Matt" <mw******@caldr ywall.comwrote in message
news:11******** **************@ p77g2000hsh.goo glegroups.com.. .
>I have table that has the following fields:

JobNumber
WeekEndingDate
ReportRequired_ 01
ReportRequired_ 02

every Friday morning the weekending date changes. I need to
automatically generate a new record for each record that has a job
number and weekending date for the new weekending date.

i.e. JobNumber = 12345, WeekEndingDate = "4/12/2007",
ReportRequired_ 01 = yes, ReportRequired_ 02 = yes

This Friday, 4/20/2007, at 12am I would need to generate a duplicate
record for all jobs that have a weekending record of 4/12/07 and grab
the settings of reportRequired fields of the previous week. I have
total visual agent that I can use to automate the query or macro but I
am not sure how i would setup that query.

Thanks

Apr 18 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
1871
by: michaaal | last post by:
How can I get a list of the date of every friday of the year? I realize this code is wrong, but maybe you'll see what I am after... Sub GetFridayList() For x = 1 to len(Date(2004)) if Date(2004,x)="Friday" then msgbox (Date2004) Next End Sub
3
1656
by: Henro V | last post by:
I made this table in which we registrate our working hours It is in fact quite simple: DayOfTheWeek Date StartTime Endtime Lunch Travel ... ... ... Total WorktimeThisDay This would look like: Tuesday 01-01-04 ... ... ...
7
1359
by: Mike | last post by:
I am having trouble with the new record property. When I attempt to place the code under a command button that says the following: ''''CODE STARTS HERE'''' Private Sub Cause_Entry_Click() Dim MyForm As Variant Dim intnewrec As Integer
3
3047
by: Peter | last post by:
Has anyone written any code to find the date of every other Friday of the year? Is there an easy way of doing this?
4
1456
by: CK | last post by:
Good Morning, I have a person table with personID. I have a personRate table with personID, rateID, and effectiveDate. I need to select fields from personRate, but I want the fields from the proper record. I need the one child record that has the most current date of the largest rateID. For example a person may have many rate records. I need the record that has
18
2000
by: Jen | last post by:
Is it possible (how) to display a new record every week (or day) from a recordset?
2
1738
by: Maximus | last post by:
I need some help. I have an .asp page that interfaces with an Access table (wjs_SuperInput). The .asp page looks to the table and pulls a recordset based on a job number, 12345, and a weekending date, mm/dd/ yyyy. If there is no record for that job number with that particular weekending date a record is created, and the page refreshes, with form fields to allow the user to edit the record and then update it. Fields in the table are: ...
7
8696
kcdoell
by: kcdoell | last post by:
Good morning everyone: I created a form and set the default view as a continuous form. Basically the form is displaying records in which the user can add or edit new ones. The record source for this form is a query that I built that is based on a table. I have been working on this for several weeks and now I have been told that many times when a user wants to create a new record, much of the information that is displayed in a...
0
8984
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9530
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9363
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9312
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
6793
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6073
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4593
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3300
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2206
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.