Need help with code for form entry using Username and Password

majette97

Registered User.
Local time
Today, 12:34
Joined
Apr 26, 2001
Messages
23
What code is needed to be able to have user enter Username and Password then click on login button (of form) to access the database? Only accessing the records/data pertaining to him/her?

Also, once the user has access to the data, and have updated the data, what code is needed to auto update the query which in-turn will create a table to create a report using beginning and end dates?

Any assistance would be greatly appreciated!Thanks!!!
 
More information please. What sort of database are you using? Is your data in Access or in SQL Server or Oracle or ??? The answer depends on this.

Then on part two, once a table is updated, then any query will include the latest data. If you want to set up a query that uses beginning & end dates, start by looking in Access Help for parameter queries. Once you have that query returning the right data, you can create a form that will allow the user to enter the dates.
 
ChrisRR, we are using an Access database and the data is in Access. Also, see below the code that has been written and can you assist?

The following code for a command button should close this form and open the switchboard form; once I click the button and the username and password has been validated. Right now it doesn't do anything when you click the OK button.
Thank you for any assistance.

Option Compare Database
Option Explicit


Sub cmdOK_Click()
Dim stDocName As String
Dim stLinkCriteria As String

'first check if both entrys are filled
If Len(txtUserName.Text) And Len(txtPassWord.Text) Then
If Not CheckAuthorisation(txtUserName.Text, txtPassWord.Text) Then
GoTo cmdOK_FAIL
End If
End If

stDocName = "Time Card Menu"
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_cmdOK_Click:
Exit Sub

cmdOK_FAIL:
Unload Me
MsgBox Err.Description
Resume Exit_cmdOK_Click
End Sub

Private Function CheckAuthorisation(ByRef strUserName As String, ByRef strPassWord As String)

Dim Db As Database
Dim rs As Recordset
Dim SQL As String
On Error GoTo CheckAuthorisation_FAIL

CheckAuthorisation = False
Set Db = OpenDatabase("timecard")
SQL = " SELECT * FROM Resources " + _
" WHERE ResName = '" + strUserName + "'" + _
" AND ResourceNo = " ' + strPassWord + "'"
Set rs = Db.OpenRecordSet(SQL)

If Not rs.NoMatch Then
CheckAuthorisation = True
Exit Function
End If

CheckAuthorisation_FAIL:

End Function
 

Users who are viewing this thread

Back
Top Bottom