Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 70
  • Last Modified:

Open Process in Access 2013 will not open form

I have a form "fPreproject" which is supposed to automatically open when I click on my database.  When I click on debug, the error pops up as existing in the third line of the code below (DoCmd.OpenForm "fPREPROJECT",,,,,acHidden.)  The code appears simple enough, but I keep receiving the 2501 error code which says, "the openform action was cancelled".  I am new to coding.  Am I incorrectly calling up the form to open in Access 2013.  I am used to Access 2003, so I thought maybe I am using an incorrect syntax.

Public Function OpenfPREPROJECT()
    Application.Echo False
    DoCmd.OpenForm "fPREPROJECT", , , , , acHidden
    Application.Echo True
End Function

Public Function OpenProcs()
Application.Echo False
Call UseAQMenuBar
Call SetEnterOption
Call genCurrDBPath
Call AssistantOff
Call qProjectDataOpen
Call qProjPenDataOpen
Application.Echo False
DoCmd.OpenForm "fPREPROJECT", , , , , acHidden
DoCmd.OpenForm "fAQSplashForm"
Application.Echo True
End Function

Open in new window

0
Tammy Allen
Asked:
Tammy Allen
  • 3
  • 3
  • 2
1 Solution
 
COACHMAN99Commented:
is the form running any code when it loads?
and/or do you have the form set as the startup item for the database?
0
 
crystal (strive4peace) - Microsoft MVP, AccessRemote Training and ProgrammingCommented:
as asked, is there code behind the form you are opening? It sounds to me like there might be an OPEN event that is being cancelled
0
 
Tammy AllenAuthor Commented:
There is an Open Event associated with the file.  The open event code is:

Private Sub Form_Open(Cancel As Integer)
Dim db As DAO.Database
Set db = CurrentDb()
'load the Rowsource for [prmEmpNo]
'code below performs a query and loads information
'from the EMPLOYEE table into the Rowsource
Dim EmpInfo As DAO.Recordset
Dim i As Integer
Dim qte
qte = Chr(34)
Dim prm As Parameter
Dim QD As DAO.QueryDef
    Set QD = db.QueryDefs("qCmbEmpInfo2")
For i = 0 To QD.Parameters.Count - 1
    Set prm = QD.Parameters(i)
    prm.Value = Eval(prm.Name)
Next i
Set EmpInfo = QD.OpenRecordset(dbOpenDynaset)
EmpInfo.MoveFirst
Do Until EmpInfo.EOF
    [prmEmpNo].RowSource = [prmEmpNo].RowSource & qte & EmpInfo![EmpInfo] & qte & ";" & qte & EmpInfo![Empl_No] & qte & ";"
EmpInfo.MoveNext
Loop
EmpInfo.Close
'this adds an additional entriy at the beginning of Rowsource
[prmEmpNo].RowSource = qte & "AllActive" & qte & ";" & qte & "Actv" & qte & ";" & [prmEmpNo].RowSource
'this adds additional entries to the end of Rowsource
[prmEmpNo].RowSource = [prmEmpNo].RowSource & qte & "TOXICS" & qte & ";" & qte & "tox" & qte & ";"
[prmEmpNo].RowSource = [prmEmpNo].RowSource & qte & "STATIONARY SOURCE" & qte & ";" & qte & "cmp" & qte & ";"
[prmEmpNo].RowSource = [prmEmpNo].RowSource & qte & "AllEmployees" & qte & ";" & qte & "AllEmployees" & qte & ";"
'sets values of startup parameter fields
Forms![fPREPROJECT]![prmProjectGroup] = "AllProjects"
Forms![fPREPROJECT]![prmOpenClosed] = 2
Forms![fPREPROJECT]![prmEmpNo] = "Actv"
DoCmd.Maximize
Me![fProjectData].SetFocus

End Sub

Open in new window


The complete Open code is:

Public Function OpenfPREPROJECT()
    Application.Echo False
    DoCmd.OpenForm "fPREPROJECT", , , , , acHidden
    Application.Echo True
End Function

Public Function OpenProcs()
Application.Echo False
Call UseAQMenuBar
Call SetEnterOption
Call genCurrDBPath
Call AssistantOff
Call qProjectDataOpen
Call qProjPenDataOpen
Application.Echo False
DoCmd.OpenForm "fPREPROJECT", , , , , acHidden
DoCmd.OpenForm "fAQSplashForm"
Application.Echo True
End Function

Open in new window



Also, I have attached the error messages.  This particular form will not allow me to select layout view, only design view.  This form used to open in layout view, which no longer seems to be an option

error codes associated with opening fPREPROJECT form
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
crystal (strive4peace) - Microsoft MVP, AccessRemote Training and ProgrammingCommented:
you would have to post all the code in the procedures that were called -- as well specify relevant portions of your database structure before we could have a hope to know what is really going on ... and it would take quite a bit of time to do that.
0
 
COACHMAN99Commented:
If you disable different sections of the code does the form stay open?
Try adding error trapping and reporting code to the functions in play. This way you should get an idea of which error in which code is the problem.
I sometimes increment a variable for every line of code and display the variable in the error routine so I know where it is failing.
0
 
Tammy AllenAuthor Commented:
I am going to check back in the original code from Access 2003 to see if some code changes were not documented correctly.
0
 
COACHMAN99Commented:
I don't know your level of VBA expertise, but disabling code is usually the quickest way to zoom in on the problem.
initially, comment all and run, then (if no error) gradually enable code from the top and run until the error returns.

Alternatively, put a break watch on the first line ('Set db = CurrentDb()') , and step (F8) line-by-line until the error comes.
0
 
Tammy AllenAuthor Commented:
COACHMAN99 always provide precise knowledge of troubleshooting.  This particular code will need full re-working.
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

  • 3
  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now