mattpearcey
Technical User
I have a database that has grown to a state where i need more people to use it, but to be able to view different records.
I initially conquered this, by having 3 seperate frontends for each of my branches. With tabs showing the difference records for each branch. Therefore, branch A could not see the records of branch B, and so on. However, i now need to set this up so that within the branches, Salesperson A can only see those records assigned to him within that branch. Now i have made this work fine with the below code
Private Sub Command8_Click()
On Error GoTo Err_Command8_Click
Dim SQL$, rs
Dim stDocName As String
Dim stLinkCriteria As String
logon = SalesPersonAfrica
SQL$ = "select * from tblSalesPerson where SalesPersonAfrica = '" & logon & "' and password = '" & Password & "'"
Set rs = CurrentDb().OpenRecordset(SQL$)
If Not rs.EOF Then
stDocName = "BankDetails" '"fsubBankDetails" '"BankDetails"
DoCmd.OpenForm stDocName, , , stLinkCriteria
Else
MsgBox ("Logon failed"
End If
Exit_Command8_Click:
Exit Sub
Err_Command8_Click:
MsgBox Err.Description
Resume Exit_Command8_Click
End Sub
This works by having a opening form that the users sees to begin with, and they select their username and is mirrored in the main table. IF they enter that, and their correct password, which i set in a salesperson table, then they open the database to view all the records with their name assigned to them.
However, my problem is that i need this to work also for salesmanagers. I need them to see all the records, so i need to set a query to make them select their username (which is not assigned to anything) to view all records. But i cannot get this to work. It just comes up with no records at all. The code i have is below, that doesnt work.
Please help.
Option Compare Database
Public logon
Function strLogon()
If logon = "Orla Mahon" Then
strLogon = "Rob Koch and Orla Mahon and Neil Herbert"
Else
strLogon = logon
End If
MsgBox (strLogon)
End Function Thank you for your help already.
Matt Pearcey
I initially conquered this, by having 3 seperate frontends for each of my branches. With tabs showing the difference records for each branch. Therefore, branch A could not see the records of branch B, and so on. However, i now need to set this up so that within the branches, Salesperson A can only see those records assigned to him within that branch. Now i have made this work fine with the below code
Private Sub Command8_Click()
On Error GoTo Err_Command8_Click
Dim SQL$, rs
Dim stDocName As String
Dim stLinkCriteria As String
logon = SalesPersonAfrica
SQL$ = "select * from tblSalesPerson where SalesPersonAfrica = '" & logon & "' and password = '" & Password & "'"
Set rs = CurrentDb().OpenRecordset(SQL$)
If Not rs.EOF Then
stDocName = "BankDetails" '"fsubBankDetails" '"BankDetails"
DoCmd.OpenForm stDocName, , , stLinkCriteria
Else
MsgBox ("Logon failed"
End If
Exit_Command8_Click:
Exit Sub
Err_Command8_Click:
MsgBox Err.Description
Resume Exit_Command8_Click
End Sub
This works by having a opening form that the users sees to begin with, and they select their username and is mirrored in the main table. IF they enter that, and their correct password, which i set in a salesperson table, then they open the database to view all the records with their name assigned to them.
However, my problem is that i need this to work also for salesmanagers. I need them to see all the records, so i need to set a query to make them select their username (which is not assigned to anything) to view all records. But i cannot get this to work. It just comes up with no records at all. The code i have is below, that doesnt work.
Please help.
Option Compare Database
Public logon
Function strLogon()
If logon = "Orla Mahon" Then
strLogon = "Rob Koch and Orla Mahon and Neil Herbert"
Else
strLogon = logon
End If
MsgBox (strLogon)
End Function Thank you for your help already.
Matt Pearcey