Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Waiting for input from a form

0 views
Skip to first unread message

Rod

unread,
Nov 14, 2007, 4:55:00 AM11/14/07
to
Half-way through my code, the user needs to supply information from a
combo-box.

How do I pause my code while the user makes their selection? I cannot use
InputBox or MsgBox, since I need the combobox object. How do I open an
ordinary form and then wait for the user to press "OK" (or whatever button I
create) before continuing to execute the code? Setting the Modal property to
Yes doesn't help.

Thanks

Pieter Wijnen

unread,
Nov 14, 2007, 5:07:36 AM11/14/07
to
Something Like

DoCmd.OpenForm "MyForm"

While FisLoaded("MyForm")
DoEvents
Wend

Use your own favourite FisLoaded (thers's one at http://www.mvps.org/access)

HtH

Pieter


"Rod" <R...@discussions.microsoft.com> wrote in message
news:107E9CE0-20E5-4575...@microsoft.com...

Douglas J. Steele

unread,
Nov 14, 2007, 7:39:18 AM11/14/07
to
Why not open the form using acDialog?

DoCmd.OpenForm "MyForm", WindowMode:=acDialog


--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)


"Pieter Wijnen"
<it.isi.llegal.to.send.unsollic...@online.replace.with.norway>
wrote in message news:e7YC3XqJ...@TK2MSFTNGP03.phx.gbl...

John Spencer

unread,
Nov 14, 2007, 7:45:32 AM11/14/07
to
Can't you get the value before you start the code and just pass it in as an
argument?

If for some reason the answer is no, then try this technique.
Open the form in acDialog mode.
Hide the form when your user has input data (code the ok button to set the
form's visible property to false.
Check if the form is open and if so grab the value(s) you need
Close the form

.... Your code

'Stop processing in current procedure until form closes or is no longer
visible
DoCmd.OpenForm "YourFormname", windowmode:=acdialog
If isFormLoaded = True Then
someVariable = Forms!YourFormName!YourControlName
DoCmd.Close acForm, "YourFormname"
End if

... resume processing your code

'Sample code to check if form is loaded (works for all versions of Access up
to 2003 and probably 2007 (not tested)

Function IsFormLoaded(ByVal strFormName As String) As Boolean
' Returns True if the specified form is open in Form view or Datasheet
view.

Const conObjStateClosed = 0
Const conDesignView = 0

If SysCmd(acSysCmdGetObjectState, acForm, strFormName) <>
conObjStateClosed Then
If Forms(strFormName).CurrentView <> conDesignView Then
IsFormLoaded = True
End If
End If

End Function
--
John Spencer
Access MVP 2002-2005, 2007
Center for Health Program Development and Management
University of Maryland Baltimore County
.

"Rod" <R...@discussions.microsoft.com> wrote in message
news:107E9CE0-20E5-4575...@microsoft.com...

Pieter Wijnen

unread,
Nov 14, 2007, 8:18:11 AM11/14/07
to
Since he said that modal mode didn't work <g>
Can happen when timers are involved

Pieter

"Douglas J. Steele" <NOSPAM_djsteele@NOSPAM_canada.com> wrote in message
news:uqQOhtrJ...@TK2MSFTNGP05.phx.gbl...

Douglas J. Steele

unread,
Nov 14, 2007, 12:45:18 PM11/14/07
to
I read that as meaning he tried to set the form's Modal property to True,
which I believe is different that opening it using acDialog.

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)


"Pieter Wijnen"
<it.isi.llegal.to.send.unsollic...@online.replace.with.norway>
wrote in message news:uhEZXCsJ...@TK2MSFTNGP05.phx.gbl...

Pieter Wijnen

unread,
Nov 14, 2007, 1:37:15 PM11/14/07
to
It shouldn't be, I think. At least not as far as I recall.
I do offcourse use the acDialog Param to make sure myself, but always also
add the (superfluos) waiting loop to make sure it works under any
circumstances.

Pieter

"Douglas J. Steele" <NOSPAM_djsteele@NOSPAM_canada.com> wrote in message

news:O$KSgYuJ...@TK2MSFTNGP06.phx.gbl...

Rick Brandt

unread,
Nov 14, 2007, 7:46:27 PM11/14/07
to
"Pieter Wijnen"
<it.isi.llegal.to.send.unsollic...@online.replace.with.norway>
wrote in message news:Ojo0p0uJ...@TK2MSFTNGP05.phx.gbl...

> It shouldn't be, I think. At least not as far as I recall.
> I do offcourse use the acDialog Param to make sure myself, but always also add
> the (superfluos) waiting loop to make sure it works under any circumstances.


Modal won't relinquish focus, but it does not pause code from a calling form
like acDialog does.

--
Rick Brandt, Microsoft Access MVP
Email (as appropriate) to...
RBrandt at Hunter dot com


0 new messages