Solved

Open Process in Access 2013 will not open form

Posted on 2016-10-20
8
59 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 21
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
Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

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

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

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

In earlier versions of Windows (XP and before), you could drag a database to the taskbar, where it would appear as a taskbar icon to open that database.  This article shows how to recreate this functionality in Windows 7 through 10.
The Windows Phone Theme Colours is a tight, powerful, and well balanced palette. This tiny Access application makes it a snap to select and pick a value. And it doubles as an intro to implementing WithEvents, one of Access' hidden gems.
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…
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…

623 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