Solved

Open Process in Access 2013 will not open form

Posted on 2016-10-20
8
54 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
Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

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

The Eight Noble Truths of Backup and Recovery

How can IT departments tackle the challenges of a Big Data world? This white paper provides a roadmap to success and helps companies ensure that all their data is safe and secure, no matter if it resides on-premise with physical or virtual machines or in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Object Variable or Block Variable Not Set - Adobe Acrobat 31 68
Setting that's causing Access to crash 19 34
ADODB problem 20 38
Use after update to change dates 2 16
QuickBooks® has a great invoice interface that we were happy with for a while but that changed in 2001 through no fault of Intuit®. Our industry's unit names are dictated by RUS: the Rural Utilities Services division of USDA. Contracts contain un…
I see at least one EE question a week that pertains to using temporary tables in MS Access.  But surprisingly, I was unable to find a single article devoted solely to this topic. I don’t intend to describe all of the uses of temporary tables in t…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.

828 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