That code is straight out of a Microsoft wizard. Try this:
1. Locate the form in question and open it from the database window.
2. Carefully check the form name including all the spaces (if any)
3. Check to see if it is opening behind any other objects.
--
Arvin Meyer, MCP, MVP
http://www.datastrat.com
http://www.mvps.org/access
http://www.accessmvp.com
"Alex Agnew" <Alex
(E-Mail Removed)> wrote in message
news:B8429878-6046-47DC-A75A-(E-Mail Removed)...
>A command button that opened a form in Acess 2003 will no longer work in
> Acess 2007. This button is has VBA code in its event procdure. Other
> buttons
> that use VBA do manage to open Queries. Code below
>
> Private Sub RecordSearch_Click()
> On Error GoTo Err_RecordSearch_Click
>
> Dim stDocName As String
>
> stDocName = "RecordSearch"
> DoCmd.OpenForm stDocName, acNormal, acEdit
>
> Exit_RecordSearch_Click:
> Exit Sub
>
> Err_RecordSearch_Click:
> MsgBox Err.Description
> Resume Exit_RecordSearch_Click
> End Sub
>