Hi again
Sorry you are getting my two tasks mixed up. I don't want to create a new
table for the virtual records. I want to append to the same recordset
amending existing records.
My recordset looks like this for example (see below). The spec and
ReviewDates are already populated when sent to the user. The user has entered
Bank Holiday 1 day, Audit 4 days. As soon as they have entered the 4, I want
the Activity (and other fields) copied to the records for 03/01/07, 04/01/07
and 05/01/07.
Spec ReviewDate Activity ReviewDays
1 01/01/07 Bank Holiday 1
1 02/01/07 Audit 4
1 03/01/07
1 04/01/07
1 05/01/07
Sue
:
Hi sue,
"simply trying to create a new table with certain
field information copied into it from another table."
why not use a Make-Table query then, instead of looping?
~~~~~~~~ MAKE TABLE ~~~~~~~~
SELECT fieldlist
INTO tablename
IN c:\path\anotherdatabase.mdb
FROM tablename
WHERE conditions to process before recordset is made
GROUP BY fieldlist
HAVING conditions for fields that are grouped
ORDER BY fieldlist;
once you have copied the records, you can use an Update query to set
ReviewDays to 0
~~~~~~~~~~~ UPDATE ~~~~~~~~~~~
An Update Query first identifies the tables that are used
UPDATE table1 INNER JOIN table2 ON table1.keyfield =
table2.keyfield
Then identifies what to change
SET table1.fieldtochange = expression
Then, if you have criteria...
WHERE table.strField = 'somevalue'
AND table.numField = 99
AND table.dateField = #1/1/06#
I am a little confused, though, why you are creating a new table for
this information as opposed to using a temporary Flag (yes/no) field in
your table to mark records...
~~~~~~~~~~~ Calendar Report ~~~~~~~~~~~
I have some code that outputs information to an HTML file in a Calendar
format. If you are interested, email me and I'll send it to you. Put
"HTML Calendar Report" in the subject so I don't miss your message...
Warm Regards,
Crystal
*

have an awesome day

*
MVP Access
Remote Programming and Training
strive4peace2006 at yahoo.com
*
hughess7 wrote:
Sorry had a few days off and got out of sync. I just realised I explained
stage 1 of the process to you - DOH! Which I do also need help with though!
Stage 2, which I was asking for advice on in this post, is done at the
Specialists end. I want them to fill out entries for every date in the
quarter that they are sent, so if they enter an activity of greater than 1
ReviewDays, I want all the data in the record to copy to the record(s) for
the next day. eg 1 Jan they enter details of a 5 day audit, when they enter 5
days in the ReviewDays field I want 2, 3, 4 and 5 Jan records to be
automatically updated with the same information as the fields in 1 Jan
record. It is purely just to show on a calendar form I have, I will set
ReviewDays to equal 0 for all these records and they will not get imported
back into the live system.
Sue
:
Hi again
I'll try to explain it to you...
ReviewDays is not a calculated field. In my data I have [ReviewDate] which
is the start date of an activity then [ReviewDays] stores the number of days
the activity lasts. I do not have an end date field as the activities are not
always on consecutive days!
I am not changing any data, simply trying to create a new table with certain
field information copied into it from another table. It will be used to send
out to our specialists who amend the data in their own copy of a standalone
database and send back to us when completed. Kind of like a transfer file, we
do this currently as they do not have access to our servers and live data in
the office. Long term this is being looked at, with me getting our systems on
the web somehow, but for now we manage by using these Access 'transfer files'
(small MDBs).
The specialists have to complete a quarterly Itinerary Plan and send to us
each quarter. I want to keep their task as simple and easy for them as
possible. So I want to send them blank records for every Mon-Frid for the
next quarter and they have to fill out the blanks and return. For some dates
at the beginning of the quarter and for certain activities eg bank holidays
we will already know the information so the plan needs to be populated with
any information we already have before sending to them. eg for next quarter
we would already know the Easter bank holiday dates.
The Table [Itinerary] contains the live data we already know, the plan needs
to include data from this table and just a Date and SpecID for those days no
entry exists. I know how to append the data from [Itinerary] but I just need
some code to create the missing working (Mon-Frid) dates and SpecID. I want
to do it this way to make it easier to detect if they have missed an entry
for any day in the required quarter.
Hope this makes sense?
Thanks
Sue
:
Hi Sue,
sounds like ReviewDays is a calculated field. You should not be storing
calculated fields as you can display them with an equation anytime.
What does ReviewDays represent?
Also, why are you changing CustID and Activity?
Can you explain a bit more about your data and the purpose of your
application?
Warm Regards,
Crystal
*

have an awesome day

*
MVP Access
Remote Programming and Training
strive4peace2006 at yahoo.com
*
hughess7 wrote:
Thanks for the reply, think you've maybe slightly misunderstood what I am
trying to do though unless I don't understand your code? I do not want to
append/add records as the record with each relevant date already exists. I
want to find the record with the date and update (add data) to the rest of
the fields in the record. I want to use ReviewDays as a loop count to update
the correct number of days.
I thought something like this ? ....
set rst = db.openrecordset("select * from QuarterlyPlan)
IntDays = ReviewDays
CheckDate = ReviewDate
Do while IntDays > 1
If Weekday(CheckDate) = vbFriday then
CheckDate = CheckDate + 3
Else
CheckDate = CheckDate + 1
End If
rst.findfirst "[ReviewDate] = #" & CheckDate & "#"
rst.edit
rst.Activity = Me![Activity]
rst. CustID = Me![custid]
etc
rst. Update
IntDays = IntDays - 1
Loop
:
Hi Sue,
one way to do this would be to use code to loop through the dates and
append a record or records to the underlying table using SQL
in code behind the form, try something like this:
'~~~~~~~~~~~~~~~~~~
dim mDate as date _
, s as string
for mDate = me.Date_controlname +1 to me.Date2
s = "INSERT INTO Tablename (datefield, textfield, numberfield ) " _
& "SELECT #" & mDate & "#" _
& ", '" & me.text_controlname & "'"
& ", " & me.number_controlname
& ";"
currentdb.execute s
next mDate
doEvents
me.requery
'~~~~~~~~~~~~~~~~~~`
assuming Date2 is an unbound control containing the date to end
since you are already making a record for the first date, you would add
1 to that date for appending records using SQL
Warm Regards,
Crystal
*

have an awesome day

*
MVP Access
Remote Programming and Training
strive4peace2006 at yahoo.com
*
hughess7 wrote:
Hi all
I have a continuous form displaying data, it has the fields SpecID and
ReviewDate populated and the rest of the information is entered by a user. If
an activity lasts more than one day, I want the record details to copy to the
next date for as long as the activity lasts. ie if an activity is entered on
01/01/07 and lasts 5 days, I want to programatically update 2 - 5 Jan with
the same data. I want the code to stop if it can't find a date, but to skip
weekend dates. I then want the form to refresh to show the new data.
Can someone offer some help with the best way to do this please? Would it be
with a findfirst recordset using ReviewDate then rs.edit and rs.update?
Thanks
Sue