Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Starting MAIN program from Login Screen

Status
Not open for further replies.

stanmurphy

Technical User
Oct 14, 2000
89
Hello All,

I would like to call my main program, SCHEDULE, from a login screen after I have checked for valid username and password.

When I simply call the SCHEDULE form from the LOGIN form, I immediately get an error say that the object SCHEDULE cannot be found.

However, if I run the SCHEDULE form as the main form without calling it from LOGIN, it runs fine. Can anyone help me with this please?

My LOGIN code is below:

*********************************************************

SELECT users
SET ORDER TO username

SEEK ALLTRIM(UPPER(m.USERNAME))
IF FOUND()
IF ALLTRIM(UPPER(users.password)) == ALLTRIM(UPPER(THISFORM.TEXT1.TEXT))
STORE m.USERNAME TO m.CURRENT_USER
THISFORM.HIDE()
DO FORM SCHEDULE
ELSE
MESSAGEBOX("Password Is Incorrect. Please Try Again",0)
STORE "" TO THISFORM.TEXT1.Value
THISFORM.TEXT1.SetFocus
ENDIF
ELSE
MESSAGEBOX("That Is Not A Valid User Name. Please Try Again",0)
STORE "" TO THISFORM.TEXT1
THISFORM.COMBO1.SetFocus.VALUE
ENDIF
 
Actually, I should have said the error is "Alias SCHEDULE not found"
 
If SCHEDULE is a prg you call it by DO SCHEDULE rather than DO FORM SCHEDULE.

Jim
 
Sorry, I should have said 'call my main form'. SCHEDULE is a form.
 
Stan, you can do this a number of ways. The way I usually do it is starting with a my main program I create my global object so it's available for all routines, and then check security.

SET DEFA TO SYS(5)

* set the path to the startup, plus the subdirectories
SET PATH TO SYS(5)+SYS(2003) + ";data;progs;utils;forms;libs;reports;menus;graphics;"

SET CLASSLIB TO libs\myLib ADDITIVE
PUBLIC goApp
goApp = CREATEOBJECT('cApp')


DO LOGIN
* -- if security is included

IF goApp.logIn
DO myMenu.mpr
READ EVENT
ENDIF

* this example assumes there is a property on the container cApp (located in myLib.vcx) named login. If you prefer, you can do the form and return a value. Below:

DO LOGIN TO llLogin

* in this instance use the LOGIN forms UNLOAD event to return .T. or .F.

UNLOAD EVENT.
IF THISFORM.login = .T.
RETURN .T.
ELSE
RETURN .F.
ENDIF

Jim Osieczonek
Delta Business Group, LLC
 
The message "Alias SCHEDULE not found" suggests that VFP is looking for a table named SCHEDULE. Could this be what's happening?

Jim
 
Also, maybe the form is firing, but the alias error is in the schedule form.

DO FORM SCHEDULE
* Alias error in this form?


Jim Osieczonek
Delta Business Group, LLC
 
In my case I would create a Main.prg. Than at the top before any other code DO FORM LOGIN with passfail.
Assuming LOGIN form is your UserId and Passwaord verification form. Than if the variable passfail is
to check if the login is successful or not.

If it is succesful than let the rest of the main program code run otherwise kick the use rout. In 1001 things you would know about VFP there is agood example of this main program using a login form.

Louis
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top