Solved

Open Process in Access 2013 will not open form

Posted on 2016-10-20
8
40 Views
Last Modified: 2016-11-08
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
Comment
Question by:Tammy Allen
  • 3
  • 3
  • 2
8 Comments
 
LVL 7

Expert Comment

by:COACHMAN99
ID: 41852904
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
 
LVL 19
ID: 41853271
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
 

Author Comment

by:Tammy Allen
ID: 41853651
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
 
LVL 19
ID: 41854737
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
Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

 
LVL 7

Expert Comment

by:COACHMAN99
ID: 41854754
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
 

Author Comment

by:Tammy Allen
ID: 41857242
I am going to check back in the original code from Access 2003 to see if some code changes were not documented correctly.
0
 
LVL 7

Accepted Solution

by:
COACHMAN99 earned 500 total points
ID: 41857247
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
 

Author Closing Comment

by:Tammy Allen
ID: 41879620
COACHMAN99 always provide precise knowledge of troubleshooting.  This particular code will need full re-working.
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

In the previous article, Using a Critera Form to Filter Records (http://www.experts-exchange.com/A_6069.html), the form was basically a data container storing user input, which queries and other database objects could read. The form had to remain op…
In a multiple monitor setup, if you don't want to use AutoCenter to position your popup forms, you have a problem: where will they appear?  Sometimes you may have an additional problem: where the devil did they go?  If you last had a popup form open…
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now