Question about the code on a button now working.

  • Thread starter Thread starter steve12173
  • Start date Start date
S

steve12173

I had created a database in Access 2003 and now my company is switching to
Office 2007. The database works fine except, for the button to run a query
after the criteria has been entered on a form.

Here is the code on the button:

Private Sub Search_Click()
Me.Visible = False
DoCmd.OpenForm "frmSearchTransitionLeadsQuery", acViewNormal, acEdit
DoCmd.Close acForm, "frmSearchTransitionLeads"
End Sub

The Debugger highlights this section:

DoCmd.OpenForm "frmSearchTransitionLeadsQuery", acViewNormal, acEdit

Anyone see a problem with this?
 
On Fri, 26 Jun 2009 06:30:01 -0700, steve12173

It's the last argument: acEdit is probably not the name of a filter.

-Tom.
Microsoft Access MVP
 
steve12173 said:
I had created a database in Access 2003 and now my company is switching to
Office 2007. The database works fine except, for the button to run a
query
after the criteria has been entered on a form.

Here is the code on the button:

Private Sub Search_Click()
Me.Visible = False
DoCmd.OpenForm "frmSearchTransitionLeadsQuery", acViewNormal, acEdit
DoCmd.Close acForm, "frmSearchTransitionLeads"
End Sub

The Debugger highlights this section:

DoCmd.OpenForm "frmSearchTransitionLeadsQuery", acViewNormal, acEdit

Anyone see a problem with this?


Yes. Your "acEdit" argument is in the wrong place. It's in the FilterName
argument position, rather than in the DataMode position where I assume you
meant it. Also, the named constants you used aren't quite the official
ones, but they will work. A correct call to OpenForm would be like this:

DoCmd.OpenForm "frmSearchTransitionLeadsQuery", acNormal, , , acFormEdit

That may been broken onto two lines by the newsreader, but it should be all
on one line. You could avoide confusion over the right number of commas by
using a named parameter, like this:

DoCmd.OpenForm "frmSearchTransitionLeadsQuery", acNormal, _
DataMode:=acFormEdit
 
Tom van Stiphout said:
On Fri, 26 Jun 2009 06:30:01 -0700, steve12173

It's the last argument: acEdit is probably not the name of a filter.

-Tom.
Microsoft Access MVP
 
Back
Top