Close form button works in adNormal and not acFormDS view

G

Guest

In the on click event of a command button I have this code which opens a
popup form and then closes the form if you click the same command button.
why does it only work if the form is opened in acFormDS (Datasheet View) and
not in acNormal view? I would prefer to use the Normal view.

Thanks,
Billy Rogers
Dallas,TX



If (CurrentProject.AllForms(stDocName).IsLoaded) Then
DoCmd.Close acForm, stDocName
Else
DoCmd.OpenForm stDocName, acFormDS, , stLinkCriteria
End If
 
K

Ken Snell [MVP]

If which form is opened in datasheet view? the popup one? If that is the one
you mean, it's because you're telling the form to open in Datasheet view --
see the acFormDS argument?

Either replace it with an empty space, or use acNormal in its place.
 
G

Guest

That's exactly what is not working. When I change it to acNormal it opens
the popup form, but when i click the command button again it doesn't close
the popup form. It works if the pop up form is in datasheet view.
 
G

Guest

When i change acFormDS to acNormal it opens the form but won't close it.


Private Sub Command189_Click()
On Error GoTo Err_Command189_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "frm_qry_PrePaid_ZeroDollar_Orders"

If (CurrentProject.AllForms(stDocName).IsLoaded) Then
DoCmd.Close acForm, stDocName
Else
DoCmd.OpenForm stDocName, acFormDS, , stLinkCriteria
End If


Exit_Command189_Click:
Exit Sub

Err_Command189_Click:
MsgBox Err.Description
Resume Exit_Command189_Click

End Sub
 
K

Ken Snell [MVP]

Step through the code in debug mode when you want to click the button to
close the form. What is the value of the .IsLoaded property at that point
for when the form is in "normal" view, and when it is in "datasheet" view?
 

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