Hello.
I have an application that imports a file, then compares
the file with an older file, adding only non-duplicate
records. I have two ways to compare the files and a form
(frmCompareMethod) that pops up to let you choose what
way you would like.
What is happening is that frmCompareMethod pops up just
fine, but the function that calls it keeps running and
compares the two files in the default manner, not
allowing time for the user to make a choice. How can I
make the calling function pause until the user presses a
button on frmCompareMethod?
Thanks for any help!
Brian
GreySky - 04 Oct 2004 20:39 GMT
Open the form modally.
docmd.OpenForm "frmHi",,,,,acdialog
This causes code execution to halt until 1) the form is closed, or 2) the
form is made not visible.
David Atkins, MCP
> Hello.
>
[quoted text clipped - 14 lines]
>
> Brian
Dirk Goldgar - 04 Oct 2004 20:40 GMT
> Hello.
>
[quoted text clipped - 14 lines]
>
> Brian
It sounds as though you need to open frmCompareMethod in dialog mode.
When you open it, use something like
DoCmd.OpenForm "frmCompareMethod", WindowMode:=acDialog
That will cause the calling routine to wait until the form is closed
or -- and this is the key -- hidden.
Then, when the user makes a choice frmCompareMethod, hide the form by
setting its Visible property to False:
Me.Visible = False
At that point, your calling code will resume, and can pick up the chosen
method, close frmCompareMethod, and proceed to compare the files.
The calling code might look roughly like this:
'----- start of example code (air code) -----
Dim intMethod As Integer
DoCmd.OpenForm "frmCompareMethod", WindowMode:=acDialog
' Is the form still open? If it's closed, we'll assume the user
wanted to cancel.
If CurrentProject.AllForms("frmCompareMethod").IsLoaded Then
intMethod = Forms!frmCompareMethod!optCompareMethod
DoCmd.Close acForm, "frmCompareMethod", acSaveNo
Else
MsgBox "Comparison cancelled."
Exit Sub
End If
If intMethod = 1 Then
' Do Method 1
Else
' Do Method 2
End If
'----- end of example code -----

Signature
Dirk Goldgar, MS Access MVP
www.datagnostics.com
(please reply to the newsgroup)
Brian - 04 Oct 2004 20:56 GMT
Thanks alot for your help. Works great!!
Brian