Linking Forms

ICTkirsten

Registered User.
Local time
Today, 14:51
Joined
Jan 3, 2015
Messages
137
Hi guys,
Thank you for my time i will just get straight in :)

Current State:
Main Menu Form containing buttons to Customer Details, Registration, and Bookings.

Problem:
The Main Menu should only be accessed when login is successful.
At the moment I have created the login form and coded it so that when login is successful it leads to the Main Menu
BUT Currently the Main menu can be opened without logging in. I want the system to be able to only have the login on screen before being able to utilise the database..

Please can someone help me thank you
 
there are a number of ways to achieve this, which is right for you depends on the access abilities of the users and how secure you want to make it

At the simplest level, hide the navigation form (untick the 'display navigation pane' in file/options/current database) but users can hold down the shift key to overcome this

Alternatively you can just hide the forms you don't want to be seen by right clicking on the form and selecting hide - but users can choose to view hidden objects.

you can put some code in your main form open event that checks if the user is already logged in - and closes the system if they are not. Users can overcome this if you supply the db as an accdb (since they can open the form in design view) rather than an accde
 
hello thank you very much for your response..

as i am rather inexperienced with access could you explain your third option a bit more please as this is the direction i feel is best :)
 
Assuming your user has logged in successfully, you set a public variable in a module to indicate that - let's say it is the user name and we'll call the global variable 'usrname' so when the user has logged in you would have a bit of code before opening the main form

usrName=[user name]

[user name] being whatever you have called it

in your main form open event you would simply have a bit of code as follows

Code:
 Private Sub Form_Open(Cancel As Integer)
  
     if isnull(usrname) then application.quit
  
 End Sub

Of course, you could have a prompt instead that says the user must login or some other response as applicable to your requirements.

You can use the same technique to hide parts of forms or restrict access depending on the user - or their group if you have that level of sophistication.

Also, ensure your db has the login form set as the default form to open (see files/options/current database - display form). If you make it popup and modal and with an exit button, you can prevent the user leaving the login form until they either click the exit button or enter a correct login. However note this can also be over ridden by a sophisticated access user holding down the shift key when opening the db. This can be countered by setting the allowbypasskey - see this link for the code

http://access.mvps.org/access/general/gen0040.htm
 
thank you very much :)

as i am quite new to access the link is rather confusing (sorry)
would this be the code i use? and if so where do i insert it??

Dim dbs As Database, prp As Property
Const conPropNotFoundError = 3270

Set dbs = CurrentDb
On Error GoTo Change_Err
dbs.Properties(strPropName) = varPropValue
ChangeProperty = True

Change_Bye:
Exit Function

Change_Err:
If Err = conPropNotFoundError Then ' Property not found.
Set prp = dbs.CreateProperty(strPropName, _
varPropType, varPropValue)
dbs.Properties.Append prp
Resume Next
Else
' Unknown error.
ChangeProperty = False
Resume Change_Bye
End If
End Function
 
Actually dont worry i think i will just do what you suggested first as it is simpler and i dont think my exam board expect me to go that complex as with the second suggestion.

Thanks very much for your response youve been great help:)
 

Users who are viewing this thread

Back
Top Bottom