Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Pausing code for user response

Status
Not open for further replies.

LarryDeLaruelle

Technical User
May 19, 2000
1,055
US
I am creating a db to store and report on Pre and Post tests for children. Only one pretest is permitted but multiple post tests are possible.

If one or more post tests have already been entered, I would like to provide the user with a list of those records via a form and allow the user to select cancel or continue.

I have created the display form with appropriate notifications, a list of existing records and cancel and continue buttons. (The criteria for the underlying query for this form is the ChildID from the main form.)


In the code of the main form I use an SQL statement of open a record set with the criteria set to the ChildID. If the record count is greater than zero, I want to open the form to display the list of record/s and capture the user's response (cancel/continue).

What I can't figure out is how to proceed. I've tried putting a docmd.openform as the "Then" part of the record count test in the main form and I've tried setting up both functions and subs to open the form.

Hopefully this description provides enough detail but, if not, please ask for more.

Any suggestions will be gratefully received.

Thanks.
Larry De Laruelle
larry1de@yahoo.com

 
Wow! sounds nice, and I do like the fact you're helping all the wee little programmers to be!!!!!

It is a bit unclear as to what form is calling what, however have you considered opening the form "modally"?

Alternatively, Set a variable at the declarations level of the form

ie: Dim m_bContinue as Boolean

Then whereever you have the pausing code, have something like
...
Do While Not m_bContinue
DoEvents
Loop

m_bContinue = False (?????)
...



Then under the continue button put a bit of code like
...
m_bContinue = True
...


Hope this helps.
 
Aunty Access:

Thanks for the reply.

My main form is for entry of the Child's identifier information. I have two command buttons on this form: one to open the pre test input form and the other to open the post test input form.

As part of the code on the post test button I open a record set of tblPostTest based on the ChildID and test the value of the record count. If this value is greater than zero I then want to pause processing, display a form (frmPostList) with a list of all existing post test records for that child. The user can then determine if the post test they want to enter has already been entered or is new.

frmPostList has two button: Cancel and Continue; I do have this form set to open both as Pop Up and Modal.

I haven't tried what you suggest (Do While) but that may do the trick.

If I understand you, I would declare a module level boolean and, I assume set it's value to "False" when I test the record count. Then create a Do While loop based on that value:

If intRecCnt > 0 Then
Do While not m_bContinue
DoCmd.OpenForm("frmPostList")
Loop
End If

Right so far? Do I need to pass m_bContinue to frmPostList as an arguement or set it's value directly from frmPostList? Then, if the value becomes true, I would open the form for input of the next post test?

This is where I'm not sure how to proceed. Also, if the user selects cancel (which would leave m_bContinue as false), how do I get out of the loop?

You've gotten me a step closer any suggestions for this next part?

Thanks again.
Larry De Laruelle
larry1de@yahoo.com

 
Ok if i understand you correctly,

The when the frmPostList is just a display form to allow the user to determine if some form of data entry will be required. If so, display the data entry form, otherwise do nothing???

It also sounds like you're not taking an object orientated approach, which is fine (and faster). So with this in mind here goes

Change the module level variable to a global. This is due to the DoCmd syntax not being able to return the value of variable.

it might look something like

If intRecCnt > 0 Then
g_bContinue = false

DoCmd.OpenForm("frmPostList")

' Since the form opens modally this will stop here.

' Get the continue button on the frmPostLst to set the
' global value to true.
' Then close the form.

If g_bcontinue Then
'Open the data entry form
End if
End If
 
Aunty Access:

Thanks for your help.

I eventually solved the problem by passing control to the form called from the main form. Don't know why that didn't occur to me earlier.

When the Post Test button is clicked and one or more records already exist, the frmPostList form is displayed. If the user cancels, the form closes; I added code to the click event of the continue button to then open the input form and close the postlist form.

Working ok so far.

Thanks again.
Larry De Laruelle
larry1de@yahoo.com

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top