Sniper-BoOyA-
Registered User.
- Local time
- Today, 10:47
- Joined
- Jun 15, 2010
- Messages
- 204
Good afternoon everyone,
Before i start explaining the problem i'd like to say that these forums have been a great help, and a good resource for information regarding Access and Visual Basic.
Ok back on topic:
I am dutch so there's a chance that the names of tables and records are dutch aswell, but i will translate where needed.
I made a database-program where people from the lab can enter test results and request calculations etc..
In order to get a good view on who worked on what, the have to enter their initials everytime they enter new data into the database.
I do not like that idea and i believe it can be fixed by using a login screen where they can select their initials from a dropdown menu, and the result will be saved into a public string, which i can use in any form on a later stage..
All the initials are stored into a simple table, named tblAfkortingen (tblInitials).
Ive made a simple login form where they can select their initial, and click on 'Login' to login.
Here is the code behind that form:
Option Compare Database
Private Sub Form_Open(Cancel As Integer)
'On open set focus to combo box
Me.cboafkorting.SetFocus
End Sub
Private Sub cboafkorting_AfterUpdate()
strAfkorting = Me.cboafkorting
End Sub
This is where i wanted to 'save' the result of the drop down menu as StrAfkorting
Private Sub Login_Click()
On Error GoTo Err_Login_Click
If IsNull(Me.cboafkorting) Or Me.cboafkorting = "" Then
MsgBox "Selecteer uw afkorting a.u.b..", vbOKOnly, "Attentie!"
Exit Sub
End
Else
DoCmd.Close acForm, "frmLogin", acSaveNo
stDocName = "start"
DoCmd.OpenForm stDocName, , , stLinkCriteria
End If
This part of the code just checks if the user in question has entered her or his initial. If they havent, they get a message that said they need to select one..
Exit_Login_Click:
Exit Sub
Err_Login_Click:
MsgBox Err.Description
Resume Exit_Login_Click
End Sub
Private Sub Annuleren_Click()
On Error GoTo Err_Annuleren_Click
Dim stDocName As String
stDocName = "afsluitendb"
DoCmd.RunMacro stDocName
Exit_Annuleren_Click:
Exit Sub
Err_Annuleren_Click:
MsgBox Err.Description
If the user clicks on Annuleren (Cancel) it will execute a macro to close the database.
Ive put StrAfkorting in a public Variable in a seperate Module:
Option Compare Database
Option Explicit
Public strAfkorting As String
To test it i made a simple test form with just 2 objects. 1 text object and 1 button to close the form.
I linked the text object to StrAfkorting.
code:
Private Sub Form_Load()
Afkorting = strAfkorting
End Sub
Afkorting (Initial) is the name if the textbox i made on the form.
But unfortunately it still shows as an empty text box.
Ive tried about everything, and i am really getting desperate. Could anyone tell me what im doing wrong? And how to fix this?
I'd like to say thanks in advance!
Greetings,
Michael Schrijver
The Netherlands
Before i start explaining the problem i'd like to say that these forums have been a great help, and a good resource for information regarding Access and Visual Basic.
Ok back on topic:
I am dutch so there's a chance that the names of tables and records are dutch aswell, but i will translate where needed.
I made a database-program where people from the lab can enter test results and request calculations etc..
In order to get a good view on who worked on what, the have to enter their initials everytime they enter new data into the database.
I do not like that idea and i believe it can be fixed by using a login screen where they can select their initials from a dropdown menu, and the result will be saved into a public string, which i can use in any form on a later stage..
All the initials are stored into a simple table, named tblAfkortingen (tblInitials).
Ive made a simple login form where they can select their initial, and click on 'Login' to login.
Here is the code behind that form:
Option Compare Database
Private Sub Form_Open(Cancel As Integer)
'On open set focus to combo box
Me.cboafkorting.SetFocus
End Sub
Private Sub cboafkorting_AfterUpdate()
strAfkorting = Me.cboafkorting
End Sub
This is where i wanted to 'save' the result of the drop down menu as StrAfkorting
Private Sub Login_Click()
On Error GoTo Err_Login_Click
If IsNull(Me.cboafkorting) Or Me.cboafkorting = "" Then
MsgBox "Selecteer uw afkorting a.u.b..", vbOKOnly, "Attentie!"
Exit Sub
End
Else
DoCmd.Close acForm, "frmLogin", acSaveNo
stDocName = "start"
DoCmd.OpenForm stDocName, , , stLinkCriteria
End If
This part of the code just checks if the user in question has entered her or his initial. If they havent, they get a message that said they need to select one..
Exit_Login_Click:
Exit Sub
Err_Login_Click:
MsgBox Err.Description
Resume Exit_Login_Click
End Sub
Private Sub Annuleren_Click()
On Error GoTo Err_Annuleren_Click
Dim stDocName As String
stDocName = "afsluitendb"
DoCmd.RunMacro stDocName
Exit_Annuleren_Click:
Exit Sub
Err_Annuleren_Click:
MsgBox Err.Description
If the user clicks on Annuleren (Cancel) it will execute a macro to close the database.
Ive put StrAfkorting in a public Variable in a seperate Module:
Option Compare Database
Option Explicit
Public strAfkorting As String
To test it i made a simple test form with just 2 objects. 1 text object and 1 button to close the form.
I linked the text object to StrAfkorting.
code:
Private Sub Form_Load()
Afkorting = strAfkorting
End Sub
Afkorting (Initial) is the name if the textbox i made on the form.
But unfortunately it still shows as an empty text box.
Ive tried about everything, and i am really getting desperate. Could anyone tell me what im doing wrong? And how to fix this?
I'd like to say thanks in advance!
Greetings,
Michael Schrijver
The Netherlands