Generate new records by code? (1 Viewer)

legendv

Registered User.
Local time
Today, 07:30
Joined
Mar 18, 2002
Messages
99
What I need to do is generate a new record(s) based on selections made by the user that gets calcualted by a query then the appropriate number of records become generated. For instance:
Form 1:
User chooses if it is a one time purchase order or recurring purchase order. (One time orders - no issues) If the user chooses to have the purchase order recur, they choose frequency, (2,3,4 days) and duration, (once, twice...). Then the recurring purchase orders,(having their own autonumber) make new records.

So lets say, I have a purchase order that needs to recur every two days for three times. The original purchase order say has a unique autonumber of 8 and by the user entering the number 2 into a field (for days) and then 3 into a field (for 3 times) the recuring purchase orders are generated with their own autonumber say 1, 2, 3.

Anyone know how to make/code VBA to generate new records based on a calculation/ or maybe via queries.
 

FoFa

Registered User.
Local time
Today, 01:30
Joined
Jan 29, 2003
Messages
3,672
Here is something to think about
dim NewDate as datetime, NumOrd as integer
dim IntervalType as string, IntervalVal as integer
dim LoopCnt as Integer, Tmp as string

' Giving NumOrd as reoccurance from user, NewDate will be calculated
' IntervalType (Day or Month, Year) from User, Interval Val 2, 3 etc. from User
' NewDate inited as you wish
NewDate = Date() ' set to today

FOR LoopCnt = 2 to NumOrd ' Given the first one is added by the form
select case IntervalType
case "Day"
Tmp = "d"
case "Month"?
Tmp = "M"
case "Year"
Tmp = "y"
end select
NewDate = DateAdd(Tmp,IntervalVal,NewDate)
INSERT data here
NEXT LoopCnt
 

legendv

Registered User.
Local time
Today, 07:30
Joined
Mar 18, 2002
Messages
99
Thanks, I'll try it
 

Users who are viewing this thread

Top Bottom