How do you suspend code from continuing

M

McDal

I have this code:
Private Sub Command35_Click()
Dim mfilter As String
Dim ctl As Control
Dim varItm As Variant, intI As Integer
Dim frm As Form
Dim txtTemp2 As String
Dim stDocName2 As String
stDocName2 = "frmDefQuestions"

Set frm = Forms!frmPickDeficiency
Set ctl = frm!lstDef
For Each varItm In ctl.ItemsSelected
txtTemp2 = txtTemp2 & ctl.Column(1, varItm) & ", "

Me.HiddenTextBoxName = txtTemp2
Me.HiddenTextBoxName = Left(Me.HiddenTextBoxName,
Len(Me.HiddenTextBoxName) - 2)
If Me.lstDef.Column(3) = "yes" Then

mfilter = "DefID = " & ctl.Column(0, varItm)
MsgBox mfilter
'Forms!frmPickDeficiency!DeficientItemNum = Me.lstDef.Column(0)
DoCmd.OpenForm stDocName2, acNormal, , mfilter
'Forms!frmHoistTrolleyInspectData!RecID =
Forms!frmDefQuestions!subDefAnswer!RecID


If CurrentProject.AllForms("frmDefQuestions").IsLoaded = False
Then
'Form is closed
GoTo 100
Else
'form is open
End If

End If
100 Next varItm


I want to be able to suspend this code from going to Next Varitm until the
form "frmDefQuestions" is closed.

This code is obviously not working for me the way I want. I works but it
doesn't look like it's executing the if stmt for Currentproject.AllForms.

I only want to go get the next item in what was selected in the listbox
after I've filled out the form I opened called frmDefQuestions.

Any ideas...I'm sure someone has done this before...I'm stumped.
 
O

Ofer

Open the form as dialog
docmd.OpenForm "FormName",,,,,acDialog

that will suspend the code from continuing
 
D

Dirk Goldgar

McDal said:
I have this code:
Private Sub Command35_Click()
Dim mfilter As String
Dim ctl As Control
Dim varItm As Variant, intI As Integer
Dim frm As Form
Dim txtTemp2 As String
Dim stDocName2 As String
stDocName2 = "frmDefQuestions"

Set frm = Forms!frmPickDeficiency
Set ctl = frm!lstDef
For Each varItm In ctl.ItemsSelected
txtTemp2 = txtTemp2 & ctl.Column(1, varItm) & ", "

Me.HiddenTextBoxName = txtTemp2
Me.HiddenTextBoxName = Left(Me.HiddenTextBoxName,
Len(Me.HiddenTextBoxName) - 2)
If Me.lstDef.Column(3) = "yes" Then

mfilter = "DefID = " & ctl.Column(0, varItm)
MsgBox mfilter
'Forms!frmPickDeficiency!DeficientItemNum =
Me.lstDef.Column(0) DoCmd.OpenForm stDocName2, acNormal, ,
mfilter 'Forms!frmHoistTrolleyInspectData!RecID =
Forms!frmDefQuestions!subDefAnswer!RecID


If CurrentProject.AllForms("frmDefQuestions").IsLoaded =
False Then
'Form is closed
GoTo 100
Else
'form is open
End If

End If
100 Next varItm


I want to be able to suspend this code from going to Next Varitm
until the form "frmDefQuestions" is closed.

This code is obviously not working for me the way I want. I works but
it doesn't look like it's executing the if stmt for
Currentproject.AllForms.

I only want to go get the next item in what was selected in the
listbox after I've filled out the form I opened called
frmDefQuestions.

Any ideas...I'm sure someone has done this before...I'm stumped.

You don't need that test, and as written it wouldn't do anything useful
anyway. Just open the form in dialog mode:

DoCmd.OpenForm stDocName2, acNormal, , mfilter, , acDialog

That will pause the code until the form is closed or hidden.
 
M

McDal

THANK YOU SO MUCH!! I'VE BEEN BEATING MY HEAD AGAINST THE DESK FOR A FEW
HOURS NOW...Thanks again!
 

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