If then or Do while

pgsibson

Registered User.
Local time
Today, 17:45
Joined
Jan 24, 2008
Messages
44
Hi
I have a cmd button that, after help from members with the insert and update statements works with trial data. The on_click takes the pk from the form and creates a record in a linking table and then, after selecting a Course ID from a combo, updates the linking table on the last record and then displays relevant the information in the subform.
How do I create and then cancel a loop while the combo contains no data? The combo is deliberately set "" prior to getting the Course ID or the code would run through and add whatever is the start record in the combo.
Regards
Paul :confused:
 
For a loop you need a Do While or Do Until, so try something like:

Do Until Not IsNull(Me!Combo) And Me!Combo <> ""
...
Loop

or alternatively:

Do While IsNull(Me!Combo) Or Me!Combo <> ""
...
Loop


If you just want to make your code react to the combos value though, you may find it better to end your initial code when the combo appears and then add the rest of the code to the AfterUpdate of the combo. It depends how much info you need to retain from your original code.
 
i dont think you need a loop

you say

The on_click takes the pk from the form and creates a record in a linking table and then, after selecting a Course ID from a combo

so all you need is
a) an onclick event handler
b) something in the afterupdate event handler for the courseid combo


---------
generally you need a loop if you need to process things a multiple number of times.
 
Hi Thanks everyone

I chose to move the UPDATE elements to the after update event and use the loop
I now have other problems. Please see the last posting on my other recent query about passing parameters in Combo boxes
Regards
Paul :)
 

Users who are viewing this thread

Back
Top Bottom