Susan Zeller
szeller at cce.umn.edu
Thu Mar 6 14:56:00 CST 2003
Yes, that's it! Thank you. -----Original Message----- From: Mike and Doris Manning [mailto:mikedorism at ntelos.net] Sent: Thursday, March 06, 2003 12:03 PM To: accessd at databaseadvisors.com Subject: RE: [AccessD] AutoExec Macro Question AHA! The function returns a value... Can't do that when you use RunCode. Take that part off and it should work just fine. Doris Manning Database Administrator Hargrove Inc. www.hargroveinc.com -----Original Message----- From: accessd-admin at databaseadvisors.com [mailto:accessd-admin at databaseadvisors.com] On Behalf Of Susan Zeller Sent: Thursday, March 06, 2003 11:58 AM To: accessd at databaseadvisors.com Subject: RE: [AccessD] AutoExec Macro Question Here's the code: Public Function basLoad() As ADODB.Connection On Error GoTo eh 'sbz 11/20/02 based on code from Mark Field. 'this code creates a connection to the SQL Server database using an application role. 'When the code is run, the user stops having permissions assigned to themselves as a user 'and takes on the permissions assigned to the role. 'the user stays connected in the application role until the connection to sql server is 'terminated, which will most likely be on close of the application. Dim cnn As ADODB.Connection Set cnn = New ADODB.Connection Set cnn = CurrentProject.Connection cnn.Execute ("EXEC sp_setapprole 'Name_of_application_role', {Encrypt N 'password'}, 'odbc'") ex: Exit Function eh: mbAppCnxnOpen = False Set mAppCnxn = Nothing If Err.Number = -2147467259 Then Err.Raise 55004, , "You currently cannot connect to the database server. Please contact the OIS Help Desk 5-4564." Else MsgBox Err.Description End If GoTo ex End Function -----Original Message----- From: John Ruff [mailto:papparuff at attbi.com] Sent: Thursday, March 06, 2003 10:52 AM To: accessd at databaseadvisors.com Subject: RE: [AccessD] AutoExec Macro Question What does your basLoad function do? John V. Ruff - The Eternal Optimist :-) "Commit to the Lord whatever you do, and your plans will succeed." Proverbs 16:3 -----Original Message----- From: accessd-admin at databaseadvisors.com [mailto:accessd-admin at databaseadvisors.com] On Behalf Of Susan Zeller Sent: Thursday, March 06, 2003 8:34 AM To: accessd at databaseadvisors.com Subject: RE: [AccessD] AutoExec Macro Question Yup, it's a public function. -----Original Message----- From: Seth Galitzer [mailto:sgsax at ksu.edu] Sent: Thursday, March 06, 2003 10:14 AM To: accessd Subject: RE: [AccessD] AutoExec Macro Question Susan, One more thing to check. Are you sure basLoad is a function and not a sub? IIRC, the RunCode macro directive will only call public functions and not subs. Another way to test is to open any module and try to run the function from the Immediate Window. Just type ?basLoad anywhere in the window. If it is a function and it is public, it should run. If it doesn't run, then chances are one of those two things is not true. Seth On Thu, 2003-03-06 at 09:55, Susan Zeller wrote: > Chris, > > I know, I know! I have never used a Macro before, but in this case, > my splash screen is also my main menu page and so users return to it > over and over. The code that I wanted to call in the Autoexec Marco > creates a connetion to my SQL Server using "Application Role" > security. The way this works, I can only run this code once during > the application. If it's called a second time, it gives an error. > > I changed the name of the function from Load to basLoad can put > basLoad() in the macro. None of that works. So, I'm building a > separate splash screen and putting the basLoad on open of that form. > > Still seems a mystery to me, though. > > --Susan > -- Seth Galitzer sgsax at ksu.edu Computing Specialist http://puma.agron.ksu.edu/~sgsax Dept. of Plant Pathology Kansas State University _______________________________________________ AccessD mailing list AccessD at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/accessd Website: http://www.databaseadvisors.com _______________________________________________ AccessD mailing list AccessD at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/accessd Website: http://www.databaseadvisors.com _______________________________________________ AccessD mailing list AccessD at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/accessd Website: http://www.databaseadvisors.com _______________________________________________ AccessD mailing list AccessD at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/accessd Website: http://www.databaseadvisors.com _______________________________________________ AccessD mailing list AccessD at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/accessd Website: http://www.databaseadvisors.com