Question about the code on a button now working.

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?
 
T

Tom van Stiphout

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
 
D

Dirk Goldgar

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
 
O

o;;

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
 

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