Avatar billede schoesler Nybegynder
08. september 2002 - 08:47 Der er 7 kommentarer og
1 løsning

Modul / Password

Hej Eksperter.
Har en ide som jeg gerne vil have lavet, men ved ikke om det kan lade sige gøre.

Jeg har et modul som indeholder data om selve brugeren, data som går igen i mange fomularer.

Jeg har også forskellige brugere som logger på med password.

Er det muligt at lave et module som vælger de rigtige informationer afhændig at brugeren som er logget på.

Eksempel på modul, som viser data på en bruger
USER ID LT
PASSWORD LAILA


Option Compare Database


Function IsLoaded(ByVal strFormName As String) As Integer
' Returns True if the specified form is open in Form view or Datasheet view.
   
    Const conObjStateClosed = 0
    Const conDesignView = 0
   
    If SysCmd(acSysCmdGetObjectState, acForm, strFormName) <> conObjStateClosed Then
        If FORMS(strFormName).CurrentView <> conDesignView Then
            IsLoaded = True
        End If
    End If
   
End Function
Function ShipName()
ShipName = "LAILA THERESA"
End Function
Function CallSign()
CallSign = "OUJQ2"
End Function
Function SENO()
SENO = "herning shipping a.s 55001715"
End Function
Function NationalityOfShip()
NationalityOfShip = "Danish"
End Function
Function Homeport()
Homeport = "Struer"
End Function
Function SBT()
SBT = "408"
End Function
Function GT()
GT = "2682"
End Function
Function NT()
NT = "1305"
End Function
Function Address()
Address = "herning shipping a.s"
End Function
Function address1()
address1 = "Olufsvænget 29"
End Function
Function address2()
address2 = "DK-7400 Herning"
End Function
Function address3()
address3 = "DENMARK"
End Function
Function radar1()
radar1 = "STN ATLAS"
End Function
Function Echosounder1()
Echosounder1 = "STN ATLAS"
End Function
Function Echosounder2()
Echosounder2 = "STN ATLAS"
End Function
Function radar2()
radar2 = "STN ATLAS"
End Function
Function tank1()
tank1 = "1 Port"
End Function
Function tank2()
tank2 = "1 Starboard."
End Function
Function tank3()
tank3 = "2 Port"
End Function
Function tank4()
tank4 = "2 Starboard"
End Function
Function tank5()
tank5 = "3 Port"
End Function
Function tank6()
tank6 = "3 Starboard"
End Function
Function tank7()
tank7 = "4 Port"
End Function
Function tank8()
tank8 = "4 Starboard"
End Function
Function tank9()
tank9 = "5 Port"
End Function
Function tank10()
tank10 = "5 Starboard"
End Function
Function tank11()
tank11 = "6 Port"
End Function
Function tank12()
tank12 = "6 Starboard"
End Function
Function tank13()
tank13 = "Deck Tank Port"
End Function
Function tank14()
tank14 = "Deck Tank Std."
End Function
Function tank15()
tank15 = ""
End Function
Function tank16()
tank16 = ""
End Function
Function tank17()
tank17 = ""
End Function
Function tank18()
tank18 = ""
End Function
Function tank19()
tank19 = ""
End Function
Function tank20()
tank20 = ""
End Function
Function tank21()
tank21 = ""
End Function
Function tank22()
tank22 = ""
End Function

Hilsen Jan
Avatar billede terry Ekspert
08. september 2002 - 09:18 #1
Morning Jan!
Not QUITE sure what you are wanting, but if I'm right then I suggest the following.
You have GLOBAL variables, these are variables you declare in a module with the keyword PUBLIC this says that all forms have access to them.
Then when you start you program you call a function with the LOGIN name as a paramater. Then the function selects all the information and sets the GLOBAL variables. The user information should be in a single table to make it easy.

Once the variables are set then they can be used in ALL forms.

Is that what you are after?
Avatar billede schoesler Nybegynder
08. september 2002 - 09:27 #2
Morning Terry
Ovenstående modul er kun gyldigt for et skib, hvis et andet skib logger på applikationen, så ønsker jeg at access henter et andet modul (med andre oplysninger. Kan man ikke bruge en CASE funktion eller IF..ELSE..ENDIF på ovenstående modul ved brug af Password og userid
Jan
Avatar billede terry Ekspert
08. september 2002 - 09:42 #3
It's still early and I know nothing about ships etc so I'm still not sure what you are wanting.

Do you want to replace the whole MODULE and all of the functions depending on which SHIP we are talking about? How do you know which ship you have?

If you want things to be dynamic then you should have all of the SHIP information in tables, preferably only one.

Then depending on the login/ship you get the values necessary.
Avatar billede terry Ekspert
08. september 2002 - 09:51 #4
Lets just say you have a table containing ALL infromation for ALL ships "tblShipInfo"

With these fields
ShipName
CallSign
SENO
NationalityOfShip
.
.
.
and so on

Then when you LOGON you find the name of the ship and then either using the DLookup function or a recordset you fill in the GLOBAL variables which you can use in all forms

Example of Dlookup

CallSign = Dlookup("CallSign", "tblShipInfo", "ShipName = '" & LOGIN & "'"
Avatar billede schoesler Nybegynder
08. september 2002 - 10:00 #5
Hej Terry

Du har ret jeg ønsker at erstatte hele MODULET afhændig af hvilket skib der logger på.

Har p.t 167 formularer, så det kunne være fint, hvis jeg kunne bruge det eksisterende MODUL.

Er helt enig i din sidste kommentar, men det kræver meget arbejde.
Avatar billede terry Ekspert
08. september 2002 - 10:14 #6
Jan a module is JUST a place for putting pieces of code etc. You can NOT have the same function in two modules.

You can quite easily use the same module for ALL ships. But you will need to alter each function to take one paramater (LOGIN)

Function ShipName( Login as String) as String

    ShipName = Dlookup("CallSign", "tblShipInfo", "ShipName = '" & Login & "'"End Function


Then You call the function

TheShip = ShipName (LOGIN)

You may think it will take lots of work but once you get going it will go much faster than you think and it is MUCH more flexible if you need further functions or new ships.
Avatar billede schoesler Nybegynder
08. september 2002 - 11:56 #7
Hej Terry
Jeg køber dit svar, men jeg er endnu ikke så god til at lave kode, but learn by doing!

Tak for altid et hurtigt og godt svar

Jan
Avatar billede terry Ekspert
08. september 2002 - 12:07 #8
Thanks Jan.

When Access applications get more complicated then quite often programming will be necessary so its a good idea to learn VBA code. There is alwasy help to get here if you have problems.
Avatar billede Ny bruger Nybegynder

Din løsning...

Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.

Loading billede Opret Preview
Kategori
Dyk ned i databasernes verden på et af vores praksisnære Access-kurser

Log ind eller opret profil

Hov!

For at kunne deltage på Computerworld Eksperten skal du være logget ind.

Det er heldigvis nemt at oprette en bruger: Det tager to minutter og du kan vælge at bruge enten e-mail, Facebook eller Google som login.

Du kan også logge ind via nedenstående tjenester