Startup properties

nosaj_ccfc

Registered User.
Local time
Today, 16:21
Joined
Aug 27, 2008
Messages
12
Hello all,

Firstly I have done a searhc here on this topic, and have found some information to help me, but am still fairly stuck. My VB code knowledge is fairly limited.

I have in my database a login form where users are either Admin or Normal. I wish to change the startup propertied in VB depending on who logs in.

My solution in psuedocode

Code:
When Enter button is clicked
 
     If User = Admin Then
     StartupForm = "Switchboard"
     StartupShowDBWindow = True
 
     ElseIf User = Normal Then
     StartupForm = "Switchboard"
     StartupShowDBWindow = False
     AllowFullMenus = False
     AllowSpecialKeys = False
 
     EndIf

Am I being to ambitious thinking this code can be implemented in an OnClick event of a button?

Any help would be much appreciated.

Thanks,

nosaj
 
i am not sure about the syntax without checking, but this sort of stuff does work

however, i think that in some cases, you will find that the properties will be set for the NEXT login session, not the current session.
 
Thanks gemma, can this sort of stuff be programmed into a button click event, or would it need to be put somewhere else?
 
anywhere really

if you open a splash form, or a switchboard, you can put the code in the open event of that form

depends whether you want it to be automatic, or user controlled
 
Thanks gemma. I will try and explain what I have so far and where my errors are

I have a login screen (frmLogin), where the users enter username / password combination and click an Enter button. The following code is then attributed to the onclick event of that button

Code:
Private Sub cmdEnter_Click()
Dim dbs As CurrentProject
Set dbs = Application.CurrentProject
    If txtUser.Value = "Admin" And txtPass.Value = "admin" Then
 
        dbs.Properties(StartUpForm) = "Switchboard"
        dbs.Properties(StartUpShowDBWindow) = True
 
    ElseIf txtUser.Value = "Normal" And txtPass.Value = "normal" Then
 
        dbs.Properties(StartUpForm) = "Switchboard"
        dbs.Properties(StartUpShowDBWindow) = False
        dbs.Properties(AllowFullMenus) = False
        dbs.Properties(AllowSpecialKeys) = False
 
    Else
 
        MsgBox "Password Invalid. Please Try Again", vbOKOnly, "Invalid Entry!"
 
    End If
 
 
End Sub

When I click Enter I get an error message:

"Runtime Error 2467. The expression you entered refers to an object that is closed or doesn't exist"

and when I click debug, it always highlights the first line of each if statement the

Code:
dbs.Properties(StartUpForm) = "Switchboard"

I apologise for what I presume is poor coding, as I am not particulary versed in this type, I am only comfortable with basic selection statement and msg box type programming. Am I right is assuming that some type of object declarations are needed? I also realsise that hardcoding in the username and password is not best practice, but I just want to use these for testing.

If you or anyone could provide some more assistance that would be great.

Thanks for your help so far,

nosaj
 
I thought my error may have been to do with the fact that I have the same startup form declaration in the first line of both statements, however when I changed that, I get the same runtime 2467 error with the other lines.

would anyone have any further ideas. I have spent the last few hours searching for a solution but am drawing a blank so far, mainly due, I think, to my lack of understanding of the coding practices.

Hopefully someone can help!

thanks,

nosaj
 
Anyone have any more info on this? Sorry to be impatient, but I am at a complete loss to the solution :(

Thanks,

nosaj
 
If I recall, the property name is to be enclosed in Quotes:

dbs.Properties("StartUpForm") = "Switchboard"

dbs.Properties("StartUpShowDBWindow") = True

dbs.Properties("AllowFullMenus") = False

dbs.Properties("AllowSpecialKeys") = False

.
 
If I recall, the property name is to be enclosed in Quotes:

dbs.Properties("StartUpForm") = "Switchboard"

dbs.Properties("StartUpShowDBWindow") = True

dbs.Properties("AllowFullMenus") = False

dbs.Properties("AllowSpecialKeys") = False

.
Thanks Cyber Lynx,

I have now changed the lines to your suggestion above. Now getting a different runtime message

Code:
Runtime Error '2455'. You entered an expression that has an invalid reference to the property 'StartUpform'

The 'StartUpform' in the error message would be the other property names also.

I will do some more research on this error but if you have any ideas please let me know.

Many Thanks (again),

nosaj
 
Hello,

I have been thinking, is there someone I need to declare the properties I am using in a global scope or does Access know what they are

eg

Dim StartUpform As Type
etc
etc

Any ideasif I need to do this. I don't even know where or which Type they should be??

thanks,

nosaj
 
If the "StartUpForm" property contains nothing (empty or none) then the property will need to be created with CreateProperty.

Select a Form name in this property then try again.
 

Users who are viewing this thread

Back
Top Bottom