wizard command failure identified?

T

Thomas Wright

In the following code done by the microsoft wizard to open another form,
I've found sometimes that the command button eventually fails to work, it
seems to get corrupted in some way. Today I found to my amazement that there
is no "where condition" in some of this code as it would seem from the
variable "stLinkCriteria" and specified at the end of the DoCmd. There is no
link identified as there is with stDocName. Could this really cause the
comand to fail as I have discovered (I think)?

Private Sub Command18_Click()
On Error GoTo Err_Command18_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "Main Switchboard"
DoCmd.OpenForm stDocName , , , stLinkCriteria (Where condition)

Exit_Command18_Click:
Exit Sub

Err_Command18_Click:
MsgBox Err.Description
Resume Exit_Command18_Click

End Sub
 
A

Allen Browne

The wizard-generated code is really very basic, and has gaping holes.
Consider it sample-only. It is not good enough for use in a real-world
application.

For this particular case, the problem could be that the form is already
open. If so, the additional arguments such as WhereCondition or OpenArgs are
not applied.

You might want to test if the form is already open, and if so, ensure that
it is not Dirty (record needs saving), and then apply the stLinkCriteria as
its Filter (remembering to set FilterOn as well.)

(Of course, the problem might also be that the stLinkCriteria contains an
invalid string, and so Access is ignoring it.)
 

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

Similar Threads


Top