Copying a sequence of records with a loop - Help

E

efandango

I want to copy a sequence of records from one form to another. At the moment
this is done via a command button with the code below. But having to click
the button each time is becoming painful on my fingers (there are '000s of
mouse clicks). So what I would like to do, is for each set of records, just
click the button once, and have the code work through the chosen set of
records, copying them one by one until there are no more records for that
chosen set.

I know this could easily be done with a query, but that would not suit the
purpose of this requirement, which is essentially for a form based teaching
aid. Whereby the student has to develop memory by sequentially revealing each
item in a list. (there are many lists). So I guess that I need a loop, but I
have no experience of loops and would appreciate some help/guidance on the
matter. Once I have the loop working, I want to then insert some code to
regulate the spead of the copy process, so that different students can go
slower or faster, depending on their abilities.

This is my code that works with the command button, which follows this
simple sequence.

1. Check for blank recipient.
2. copy from donor record into blank record
3. move to next record
4. repeat process until list exhausted.



Private Sub btn_Reveal_Run_Timer_Click()
On Error GoTo Proc_Err
DoCmd.SetWarnings False

'code below checks if the recipient record fields are blank, if so, then a
copy of the first record fields are transferred to the recipient form's
records.

If IsNull(Forms.frm_Runs.[frm_Run_Reveal_Target].Form.[Run_waypoint]) Then
Forms.frm_Runs.[frm_Run_Reveal_Target].Form.[Run_waypoint] = Me.Run_waypoint
Forms.frm_Runs.[frm_Run_Reveal_Target].Form.[Postcode] = Me.Postcode
Forms.frm_Runs.[frm_Run_Reveal_Target].Form.[Run_Direction] = Me.Run_Direction
Forms.frm_Runs.[frm_Run_Reveal_Target].Form.[OrderSeq] = Me.OrderSeq
DoCmd.GoToRecord , , acNext

'If the recipient fields are not blank, then code below creates a new
record, and copies the next set of record fields.

ElseIf Not
IsNull(Forms.frm_Runs.[frm_Run_Reveal_Target].Form.[Run_waypoint]) Then
Forms![frm_Runs].[frm_Run_Reveal_Target].SetFocus
Forms![frm_Runs].[frm_Run_Reveal_Target].Form.[Run_waypoint].SetFocus
DoCmd.GoToRecord , , acNewRec

Forms.frm_Runs.[frm_Run_Reveal_Target].Form.[Run_waypoint] = Me.Run_waypoint
Forms.frm_Runs.[frm_Run_Reveal_Target].Form.[Postcode] = Me.Postcode
Forms.frm_Runs.[frm_Run_Reveal_Target].Form.[Run_Direction] = Me.Run_Direction
Forms.frm_Runs.[frm_Run_Reveal_Target].Form.[OrderSeq] = Me.OrderSeq

'code below returns to the donor form and moves to the next record, ready
for the next button push, and so on...
Forms![frm_Runs].[frm_Run_Reveal_Selector].SetFocus
Forms![frm_Runs].[frm_Run_Reveal_Selector].Form.[Run_waypoint].SetFocus
DoCmd.GoToRecord , , acNext

End If
End
Proc_Err:
MsgBox "Run Complete"
DoCmd.SetWarnings True
End Sub
 
G

GBA

As Dr. Spock would say "not logical captain"....

When you state: "this could easily be done with a query, but that would not
suit the

in programming either it works or it does not work. if a method works -
task solved.

so you should explain that a query will NOT work because ...... (which I do
not see here)

it seems you anticipate the feedback will be a query; it is not clear why
the query method is being rejected with an insistence on "looping"....
Access is event driven, so if one triggers a loop - it does its task in a
nano second vs a query which does its task in a nano second. In both cases
they do their task and then await the user's next event.






efandango said:
I want to copy a sequence of records from one form to another. At the moment
this is done via a command button with the code below. But having to click
the button each time is becoming painful on my fingers (there are '000s of
mouse clicks). So what I would like to do, is for each set of records, just
click the button once, and have the code work through the chosen set of
records, copying them one by one until there are no more records for that
chosen set.

I know this could easily be done with a query, but that would not suit the
purpose of this requirement, which is essentially for a form based teaching
aid. Whereby the student has to develop memory by sequentially revealing each
item in a list. (there are many lists). So I guess that I need a loop, but I
have no experience of loops and would appreciate some help/guidance on the
matter. Once I have the loop working, I want to then insert some code to
regulate the spead of the copy process, so that different students can go
slower or faster, depending on their abilities.

This is my code that works with the command button, which follows this
simple sequence.

1. Check for blank recipient.
2. copy from donor record into blank record
3. move to next record
4. repeat process until list exhausted.



Private Sub btn_Reveal_Run_Timer_Click()
On Error GoTo Proc_Err
DoCmd.SetWarnings False

'code below checks if the recipient record fields are blank, if so, then a
copy of the first record fields are transferred to the recipient form's
records.

If IsNull(Forms.frm_Runs.[frm_Run_Reveal_Target].Form.[Run_waypoint]) Then
Forms.frm_Runs.[frm_Run_Reveal_Target].Form.[Run_waypoint] = Me.Run_waypoint
Forms.frm_Runs.[frm_Run_Reveal_Target].Form.[Postcode] = Me.Postcode
Forms.frm_Runs.[frm_Run_Reveal_Target].Form.[Run_Direction] = Me.Run_Direction
Forms.frm_Runs.[frm_Run_Reveal_Target].Form.[OrderSeq] = Me.OrderSeq
DoCmd.GoToRecord , , acNext

'If the recipient fields are not blank, then code below creates a new
record, and copies the next set of record fields.

ElseIf Not
IsNull(Forms.frm_Runs.[frm_Run_Reveal_Target].Form.[Run_waypoint]) Then
Forms![frm_Runs].[frm_Run_Reveal_Target].SetFocus
Forms![frm_Runs].[frm_Run_Reveal_Target].Form.[Run_waypoint].SetFocus
DoCmd.GoToRecord , , acNewRec

Forms.frm_Runs.[frm_Run_Reveal_Target].Form.[Run_waypoint] = Me.Run_waypoint
Forms.frm_Runs.[frm_Run_Reveal_Target].Form.[Postcode] = Me.Postcode
Forms.frm_Runs.[frm_Run_Reveal_Target].Form.[Run_Direction] = Me.Run_Direction
Forms.frm_Runs.[frm_Run_Reveal_Target].Form.[OrderSeq] = Me.OrderSeq

'code below returns to the donor form and moves to the next record, ready
for the next button push, and so on...
Forms![frm_Runs].[frm_Run_Reveal_Selector].SetFocus
Forms![frm_Runs].[frm_Run_Reveal_Selector].Form.[Run_waypoint].SetFocus
DoCmd.GoToRecord , , acNext

End If
End
Proc_Err:
MsgBox "Run Complete"
DoCmd.SetWarnings True
End Sub
 
E

efandango

I would say to Dr Spock, "Logic and reason - two different things"...

A query will NOT work because at some pointed, as stated in the original
post; " I want to then insert some code to regulate the spead of the copy
process, so that different students can go slower or faster, depending on
their abilities".

Unless I am mistaken once a query starts, it only stops when it is finished,
whereas using code, the timing of each record copy can be controlled with
some precision.



GBA said:
As Dr. Spock would say "not logical captain"....

When you state: "this could easily be done with a query, but that would not
suit the

in programming either it works or it does not work. if a method works -
task solved.

so you should explain that a query will NOT work because ...... (which I do
not see here)

it seems you anticipate the feedback will be a query; it is not clear why
the query method is being rejected with an insistence on "looping"....
Access is event driven, so if one triggers a loop - it does its task in a
nano second vs a query which does its task in a nano second. In both cases
they do their task and then await the user's next event.






efandango said:
I want to copy a sequence of records from one form to another. At the moment
this is done via a command button with the code below. But having to click
the button each time is becoming painful on my fingers (there are '000s of
mouse clicks). So what I would like to do, is for each set of records, just
click the button once, and have the code work through the chosen set of
records, copying them one by one until there are no more records for that
chosen set.

I know this could easily be done with a query, but that would not suit the
purpose of this requirement, which is essentially for a form based teaching
aid. Whereby the student has to develop memory by sequentially revealing each
item in a list. (there are many lists). So I guess that I need a loop, but I
have no experience of loops and would appreciate some help/guidance on the
matter. Once I have the loop working, I want to then insert some code to
regulate the spead of the copy process, so that different students can go
slower or faster, depending on their abilities.

This is my code that works with the command button, which follows this
simple sequence.

1. Check for blank recipient.
2. copy from donor record into blank record
3. move to next record
4. repeat process until list exhausted.



Private Sub btn_Reveal_Run_Timer_Click()
On Error GoTo Proc_Err
DoCmd.SetWarnings False

'code below checks if the recipient record fields are blank, if so, then a
copy of the first record fields are transferred to the recipient form's
records.

If IsNull(Forms.frm_Runs.[frm_Run_Reveal_Target].Form.[Run_waypoint]) Then
Forms.frm_Runs.[frm_Run_Reveal_Target].Form.[Run_waypoint] = Me.Run_waypoint
Forms.frm_Runs.[frm_Run_Reveal_Target].Form.[Postcode] = Me.Postcode
Forms.frm_Runs.[frm_Run_Reveal_Target].Form.[Run_Direction] = Me.Run_Direction
Forms.frm_Runs.[frm_Run_Reveal_Target].Form.[OrderSeq] = Me.OrderSeq
DoCmd.GoToRecord , , acNext

'If the recipient fields are not blank, then code below creates a new
record, and copies the next set of record fields.

ElseIf Not
IsNull(Forms.frm_Runs.[frm_Run_Reveal_Target].Form.[Run_waypoint]) Then
Forms![frm_Runs].[frm_Run_Reveal_Target].SetFocus
Forms![frm_Runs].[frm_Run_Reveal_Target].Form.[Run_waypoint].SetFocus
DoCmd.GoToRecord , , acNewRec

Forms.frm_Runs.[frm_Run_Reveal_Target].Form.[Run_waypoint] = Me.Run_waypoint
Forms.frm_Runs.[frm_Run_Reveal_Target].Form.[Postcode] = Me.Postcode
Forms.frm_Runs.[frm_Run_Reveal_Target].Form.[Run_Direction] = Me.Run_Direction
Forms.frm_Runs.[frm_Run_Reveal_Target].Form.[OrderSeq] = Me.OrderSeq

'code below returns to the donor form and moves to the next record, ready
for the next button push, and so on...
Forms![frm_Runs].[frm_Run_Reveal_Selector].SetFocus
Forms![frm_Runs].[frm_Run_Reveal_Selector].Form.[Run_waypoint].SetFocus
DoCmd.GoToRecord , , acNext

End If
End
Proc_Err:
MsgBox "Run Complete"
DoCmd.SetWarnings True
End Sub
 
G

GBA

both a loop and a query - any programmatic task - runs in a nano second until
they've completed their task whether it be 3 lines or 300 lines of code...

your issue, regardless of method, is a timer function that will trigger the
method...

there is an embedded timer property in a Form; you will see in Form
Properties there is a timer value and an 'OnTimer' event....you can search on
these terms for other Q&A on this...

one could also use probably some VBA to make a trigger based on system clock
values I suppose but that isn't something at my fingertips as I've never had
the need but you should be able to find assist...

if it is repeating the same task over and over - that is simplist; otherwise
you have to structure a series of timed triggers with task A, then task B,
then task C...


efandango said:
I would say to Dr Spock, "Logic and reason - two different things"...

A query will NOT work because at some pointed, as stated in the original
post; " I want to then insert some code to regulate the spead of the copy
process, so that different students can go slower or faster, depending on
their abilities".

Unless I am mistaken once a query starts, it only stops when it is finished,
whereas using code, the timing of each record copy can be controlled with
some precision.



GBA said:
As Dr. Spock would say "not logical captain"....

When you state: "this could easily be done with a query, but that would not
suit the

in programming either it works or it does not work. if a method works -
task solved.

so you should explain that a query will NOT work because ...... (which I do
not see here)

it seems you anticipate the feedback will be a query; it is not clear why
the query method is being rejected with an insistence on "looping"....
Access is event driven, so if one triggers a loop - it does its task in a
nano second vs a query which does its task in a nano second. In both cases
they do their task and then await the user's next event.






efandango said:
I want to copy a sequence of records from one form to another. At the moment
this is done via a command button with the code below. But having to click
the button each time is becoming painful on my fingers (there are '000s of
mouse clicks). So what I would like to do, is for each set of records, just
click the button once, and have the code work through the chosen set of
records, copying them one by one until there are no more records for that
chosen set.

I know this could easily be done with a query, but that would not suit the
purpose of this requirement, which is essentially for a form based teaching
aid. Whereby the student has to develop memory by sequentially revealing each
item in a list. (there are many lists). So I guess that I need a loop, but I
have no experience of loops and would appreciate some help/guidance on the
matter. Once I have the loop working, I want to then insert some code to
regulate the spead of the copy process, so that different students can go
slower or faster, depending on their abilities.

This is my code that works with the command button, which follows this
simple sequence.

1. Check for blank recipient.
2. copy from donor record into blank record
3. move to next record
4. repeat process until list exhausted.



Private Sub btn_Reveal_Run_Timer_Click()
On Error GoTo Proc_Err
DoCmd.SetWarnings False

'code below checks if the recipient record fields are blank, if so, then a
copy of the first record fields are transferred to the recipient form's
records.

If IsNull(Forms.frm_Runs.[frm_Run_Reveal_Target].Form.[Run_waypoint]) Then
Forms.frm_Runs.[frm_Run_Reveal_Target].Form.[Run_waypoint] = Me.Run_waypoint
Forms.frm_Runs.[frm_Run_Reveal_Target].Form.[Postcode] = Me.Postcode
Forms.frm_Runs.[frm_Run_Reveal_Target].Form.[Run_Direction] = Me.Run_Direction
Forms.frm_Runs.[frm_Run_Reveal_Target].Form.[OrderSeq] = Me.OrderSeq
DoCmd.GoToRecord , , acNext

'If the recipient fields are not blank, then code below creates a new
record, and copies the next set of record fields.

ElseIf Not
IsNull(Forms.frm_Runs.[frm_Run_Reveal_Target].Form.[Run_waypoint]) Then
Forms![frm_Runs].[frm_Run_Reveal_Target].SetFocus
Forms![frm_Runs].[frm_Run_Reveal_Target].Form.[Run_waypoint].SetFocus
DoCmd.GoToRecord , , acNewRec

Forms.frm_Runs.[frm_Run_Reveal_Target].Form.[Run_waypoint] = Me.Run_waypoint
Forms.frm_Runs.[frm_Run_Reveal_Target].Form.[Postcode] = Me.Postcode
Forms.frm_Runs.[frm_Run_Reveal_Target].Form.[Run_Direction] = Me.Run_Direction
Forms.frm_Runs.[frm_Run_Reveal_Target].Form.[OrderSeq] = Me.OrderSeq

'code below returns to the donor form and moves to the next record, ready
for the next button push, and so on...
Forms![frm_Runs].[frm_Run_Reveal_Selector].SetFocus
Forms![frm_Runs].[frm_Run_Reveal_Selector].Form.[Run_waypoint].SetFocus
DoCmd.GoToRecord , , acNext

End If
End
Proc_Err:
MsgBox "Run Complete"
DoCmd.SetWarnings True
End Sub
 
E

efandango

ok, I understand your point about a loop or a query being event driven. Run
the query, give me the result - run the loop, give me the result.

I am suffering from a 'little knowledge syndrome', and the lack of technical
know-how on how and what commands and references to use to get my job done.

What I want is simple in concept. I want to have a continous form look at a
group of records (based on a Master Record No) and reveal them one-by-one
until that group is exhausted. In between each new record 'reveal' I want
some kind of timing mechanism that will alow a lapse of say 2 seconds between
each reveal.

Will the embedded timer that you suggest be able to do that, or is it a
timer that will just do an action once depending on its timed setting? I
looked at the help file on this property but it seemed to suggest that the
timer will only work between event calls, what I can't get my head around is
that once I make an event call; namely run query, that then means the event
call is only required once and I do not get another opportunity to request
the next record. (if that makes sense?...)





GBA said:
both a loop and a query - any programmatic task - runs in a nano second until
they've completed their task whether it be 3 lines or 300 lines of code...

your issue, regardless of method, is a timer function that will trigger the
method...

there is an embedded timer property in a Form; you will see in Form
Properties there is a timer value and an 'OnTimer' event....you can search on
these terms for other Q&A on this...

one could also use probably some VBA to make a trigger based on system clock
values I suppose but that isn't something at my fingertips as I've never had
the need but you should be able to find assist...

if it is repeating the same task over and over - that is simplist; otherwise
you have to structure a series of timed triggers with task A, then task B,
then task C...


efandango said:
I would say to Dr Spock, "Logic and reason - two different things"...

A query will NOT work because at some pointed, as stated in the original
post; " I want to then insert some code to regulate the spead of the copy
process, so that different students can go slower or faster, depending on
their abilities".

Unless I am mistaken once a query starts, it only stops when it is finished,
whereas using code, the timing of each record copy can be controlled with
some precision.



GBA said:
As Dr. Spock would say "not logical captain"....

When you state: "this could easily be done with a query, but that would not
suit the
purpose"

in programming either it works or it does not work. if a method works -
task solved.

so you should explain that a query will NOT work because ...... (which I do
not see here)

it seems you anticipate the feedback will be a query; it is not clear why
the query method is being rejected with an insistence on "looping"....
Access is event driven, so if one triggers a loop - it does its task in a
nano second vs a query which does its task in a nano second. In both cases
they do their task and then await the user's next event.






:

I want to copy a sequence of records from one form to another. At the moment
this is done via a command button with the code below. But having to click
the button each time is becoming painful on my fingers (there are '000s of
mouse clicks). So what I would like to do, is for each set of records, just
click the button once, and have the code work through the chosen set of
records, copying them one by one until there are no more records for that
chosen set.

I know this could easily be done with a query, but that would not suit the
purpose of this requirement, which is essentially for a form based teaching
aid. Whereby the student has to develop memory by sequentially revealing each
item in a list. (there are many lists). So I guess that I need a loop, but I
have no experience of loops and would appreciate some help/guidance on the
matter. Once I have the loop working, I want to then insert some code to
regulate the spead of the copy process, so that different students can go
slower or faster, depending on their abilities.

This is my code that works with the command button, which follows this
simple sequence.

1. Check for blank recipient.
2. copy from donor record into blank record
3. move to next record
4. repeat process until list exhausted.



Private Sub btn_Reveal_Run_Timer_Click()
On Error GoTo Proc_Err
DoCmd.SetWarnings False

'code below checks if the recipient record fields are blank, if so, then a
copy of the first record fields are transferred to the recipient form's
records.

If IsNull(Forms.frm_Runs.[frm_Run_Reveal_Target].Form.[Run_waypoint]) Then
Forms.frm_Runs.[frm_Run_Reveal_Target].Form.[Run_waypoint] = Me.Run_waypoint
Forms.frm_Runs.[frm_Run_Reveal_Target].Form.[Postcode] = Me.Postcode
Forms.frm_Runs.[frm_Run_Reveal_Target].Form.[Run_Direction] = Me.Run_Direction
Forms.frm_Runs.[frm_Run_Reveal_Target].Form.[OrderSeq] = Me.OrderSeq
DoCmd.GoToRecord , , acNext

'If the recipient fields are not blank, then code below creates a new
record, and copies the next set of record fields.

ElseIf Not
IsNull(Forms.frm_Runs.[frm_Run_Reveal_Target].Form.[Run_waypoint]) Then
Forms![frm_Runs].[frm_Run_Reveal_Target].SetFocus
Forms![frm_Runs].[frm_Run_Reveal_Target].Form.[Run_waypoint].SetFocus
DoCmd.GoToRecord , , acNewRec

Forms.frm_Runs.[frm_Run_Reveal_Target].Form.[Run_waypoint] = Me.Run_waypoint
Forms.frm_Runs.[frm_Run_Reveal_Target].Form.[Postcode] = Me.Postcode
Forms.frm_Runs.[frm_Run_Reveal_Target].Form.[Run_Direction] = Me.Run_Direction
Forms.frm_Runs.[frm_Run_Reveal_Target].Form.[OrderSeq] = Me.OrderSeq

'code below returns to the donor form and moves to the next record, ready
for the next button push, and so on...
Forms![frm_Runs].[frm_Run_Reveal_Selector].SetFocus
Forms![frm_Runs].[frm_Run_Reveal_Selector].Form.[Run_waypoint].SetFocus
DoCmd.GoToRecord , , acNext

End If
End
Proc_Err:
MsgBox "Run Complete"
DoCmd.SetWarnings True
End Sub
 
G

GBA

well - the easiest approach, by far - is to first create the form (or is it a
report they are looking at...not sure?...concept is the same) displaying all
info the way ultimately it would look if all info is revealed....and then
time/trigger the visible/not visible property of sets of fields/displays to
occur one after the other....

Concept is simple; but implementation can't be considered simple in that it
is not an embedded vanilla Access feature and so does require some
vba...maybe not hard at all for many of the coding developers but not simple
for a beginner...

this presumes that the data is not interactive and all you have to do is
change the visible property and refresh the form...

if the data values is/are interactively dependent, then of course you have
the user 'event' of entering data to contribute to timing/triggering
experience; and the entered data somehow must be a relevant parameter to some
query one supposes...

but in the end the query-vs-loop only 'returns' the data requested in a nano
second...the slow/gradual display is event driven either by a timer control
or user triggered event...

also - you say it is a continuous form; this means it reveals first one
record, then two records, then three records::: in a continuous form you can
not control how many records display thru form's field visible manipulation -
- with this approach it is the underlying query source that must have a
result of only 1 record, then 2 records, then 3 records;;;;;

so when I write the about the easiest method above - it presumes you can get
all the data in one query upfront; then you can put all the displayable info
into one form and manipulate the visibility of select fields...


efandango said:
ok, I understand your point about a loop or a query being event driven. Run
the query, give me the result - run the loop, give me the result.

I am suffering from a 'little knowledge syndrome', and the lack of technical
know-how on how and what commands and references to use to get my job done.

What I want is simple in concept. I want to have a continous form look at a
group of records (based on a Master Record No) and reveal them one-by-one
until that group is exhausted. In between each new record 'reveal' I want
some kind of timing mechanism that will alow a lapse of say 2 seconds between
each reveal.

Will the embedded timer that you suggest be able to do that, or is it a
timer that will just do an action once depending on its timed setting? I
looked at the help file on this property but it seemed to suggest that the
timer will only work between event calls, what I can't get my head around is
that once I make an event call; namely run query, that then means the event
call is only required once and I do not get another opportunity to request
the next record. (if that makes sense?...)





GBA said:
both a loop and a query - any programmatic task - runs in a nano second until
they've completed their task whether it be 3 lines or 300 lines of code...

your issue, regardless of method, is a timer function that will trigger the
method...

there is an embedded timer property in a Form; you will see in Form
Properties there is a timer value and an 'OnTimer' event....you can search on
these terms for other Q&A on this...

one could also use probably some VBA to make a trigger based on system clock
values I suppose but that isn't something at my fingertips as I've never had
the need but you should be able to find assist...

if it is repeating the same task over and over - that is simplist; otherwise
you have to structure a series of timed triggers with task A, then task B,
then task C...


efandango said:
I would say to Dr Spock, "Logic and reason - two different things"...

A query will NOT work because at some pointed, as stated in the original
post; " I want to then insert some code to regulate the spead of the copy
process, so that different students can go slower or faster, depending on
their abilities".

Unless I am mistaken once a query starts, it only stops when it is finished,
whereas using code, the timing of each record copy can be controlled with
some precision.



:

As Dr. Spock would say "not logical captain"....

When you state: "this could easily be done with a query, but that would not
suit the
purpose"

in programming either it works or it does not work. if a method works -
task solved.

so you should explain that a query will NOT work because ...... (which I do
not see here)

it seems you anticipate the feedback will be a query; it is not clear why
the query method is being rejected with an insistence on "looping"....
Access is event driven, so if one triggers a loop - it does its task in a
nano second vs a query which does its task in a nano second. In both cases
they do their task and then await the user's next event.






:

I want to copy a sequence of records from one form to another. At the moment
this is done via a command button with the code below. But having to click
the button each time is becoming painful on my fingers (there are '000s of
mouse clicks). So what I would like to do, is for each set of records, just
click the button once, and have the code work through the chosen set of
records, copying them one by one until there are no more records for that
chosen set.

I know this could easily be done with a query, but that would not suit the
purpose of this requirement, which is essentially for a form based teaching
aid. Whereby the student has to develop memory by sequentially revealing each
item in a list. (there are many lists). So I guess that I need a loop, but I
have no experience of loops and would appreciate some help/guidance on the
matter. Once I have the loop working, I want to then insert some code to
regulate the spead of the copy process, so that different students can go
slower or faster, depending on their abilities.

This is my code that works with the command button, which follows this
simple sequence.

1. Check for blank recipient.
2. copy from donor record into blank record
3. move to next record
4. repeat process until list exhausted.



Private Sub btn_Reveal_Run_Timer_Click()
On Error GoTo Proc_Err
DoCmd.SetWarnings False

'code below checks if the recipient record fields are blank, if so, then a
copy of the first record fields are transferred to the recipient form's
records.

If IsNull(Forms.frm_Runs.[frm_Run_Reveal_Target].Form.[Run_waypoint]) Then
Forms.frm_Runs.[frm_Run_Reveal_Target].Form.[Run_waypoint] = Me.Run_waypoint
Forms.frm_Runs.[frm_Run_Reveal_Target].Form.[Postcode] = Me.Postcode
Forms.frm_Runs.[frm_Run_Reveal_Target].Form.[Run_Direction] = Me.Run_Direction
Forms.frm_Runs.[frm_Run_Reveal_Target].Form.[OrderSeq] = Me.OrderSeq
DoCmd.GoToRecord , , acNext

'If the recipient fields are not blank, then code below creates a new
record, and copies the next set of record fields.

ElseIf Not
IsNull(Forms.frm_Runs.[frm_Run_Reveal_Target].Form.[Run_waypoint]) Then
Forms![frm_Runs].[frm_Run_Reveal_Target].SetFocus
Forms![frm_Runs].[frm_Run_Reveal_Target].Form.[Run_waypoint].SetFocus
DoCmd.GoToRecord , , acNewRec

Forms.frm_Runs.[frm_Run_Reveal_Target].Form.[Run_waypoint] = Me.Run_waypoint
Forms.frm_Runs.[frm_Run_Reveal_Target].Form.[Postcode] = Me.Postcode
Forms.frm_Runs.[frm_Run_Reveal_Target].Form.[Run_Direction] = Me.Run_Direction
Forms.frm_Runs.[frm_Run_Reveal_Target].Form.[OrderSeq] = Me.OrderSeq

'code below returns to the donor form and moves to the next record, ready
for the next button push, and so on...
Forms![frm_Runs].[frm_Run_Reveal_Selector].SetFocus
Forms![frm_Runs].[frm_Run_Reveal_Selector].Form.[Run_waypoint].SetFocus
DoCmd.GoToRecord , , acNext

End If
End
Proc_Err:
MsgBox "Run Complete"
DoCmd.SetWarnings True
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top