Solved

Ensure the codes would be fired at startup

Posted on 2015-01-28
8
37 Views
Last Modified: 2015-09-09
Hi,
I have these codes

Option Compare Database

Public Function InitApplication()
Dim strTokens() As String
Dim strToken() As String

strCommand = Command()
strTokens = Split(strCommand, "&")
For i = 0 To UBound(strTokens)
  strToken = Split(strTokens(i), "=")
  If strToken(0) = "Report" Then strReport = strToken(1)
  If strToken(0) = "UserName" Then strUserName = strToken(1)
  If strToken(0) = "Password" Then strPassword = strToken(1)
Next i

If strUserName <> "" And strPassword <> "" Then
  'bypass login dialog; just validate login
  If Not IsValidLogin(strUserName, strPassword) Then DoCmd.Quit

Else
  DoCmd.OpenForm "Logon"

If strReport <> "" Then DoCmd.OpenReport strReport

Open in new window


within one module of .adp project, written by Access 2007. How to ensure such codes would be fired upon the startup of the project?
0
Comment
Question by:HuaMinChen
[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
  • 4
  • 4
8 Comments
 
LVL 27

Expert Comment

by:MacroShadow
ID: 40576862
It is a little complicated since the connection to SQL is established before any code runs. See this accepted solution for several workarounds. http://www.experts-exchange.com/Database/MS_Access/Q_25342305.html#a27667828
0
 
LVL 11

Author Comment

by:HuaMinChen
ID: 40576873
Can you show with more details, to what I should apply to the codes? Thanks.
0
 
LVL 27

Expert Comment

by:MacroShadow
ID: 40576915
You can create an AutoExec macro which calls the InitApplication function. Note, a connection will be established before the macro runs.
0
Quiz: What Do These Organizations Have In Common?

Hint: Their teams ended up taking quizzes, too.

 
LVL 11

Author Comment

by:HuaMinChen
ID: 40576936
Thanks. Can I have more details/demonstration to your suggested way?
0
 
LVL 27

Accepted Solution

by:
MacroShadow earned 500 total points
ID: 40577031
Create a new macro, name it AutoExec, set it to run InitApplication.
0
 
LVL 11

Author Comment

by:HuaMinChen
ID: 40577034
Must we run it through one Excel file, right? Can I have more details to refer to the module of one .adp access project?
0
 
LVL 27

Expert Comment

by:MacroShadow
ID: 40577449
I'm not sure how Excel is in the picture, an adp is an access interface used to access sql db's.
0
 
LVL 11

Author Comment

by:HuaMinChen
ID: 40579216
If there is a way to directly point to one report within one .adp project, I think better to have one example/demonstration for doing this. Thanks.
0

Featured Post

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Question has a verified solution.

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

Preparing an email is something we should all take special care with – especially when the email is for somebody you may not know very well. The pressures of everyday working life stacked with a hectic office environment can make this a real challen…
A quick Powershell script I wrote to find old program installations and check versions of a specific file across the network.
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

724 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