Ok When you create the parent record or any other table that visislbe to the user then you need to have addtional fields in the table such as:
DateCreated
CreatedBy
LastUpdatedDate
LastUpdatedBy
In these fields you would record the username or the primary key form your users table. Then in your forms or in any queries that include the parent table filter them to be for that user only.
So for example:
Jon Smith logs in as JSmith in the users table his Primary Key = 5
TblUsers
UserId:5 - PK
UserName:JSmith
Password:***
TblSales
SalesId:1 - PK
CustomerID: 33 - FK
.....
CreatedBy:5
CreatedDate: 01/01/2009
UpdatedBy:5
UpdatedDate: 01/10/2009
Next Create a Public Variable in a standard module
Code:
Public LngUser As Long
Next create a Public function in the same standard module
Code:
Public Function MyCurrentUser() As Long
MyCurrentUser = LngUser
End Function
Now when the user logs into the application and their username and password is verified you pass the users id to the LngUser variable
LngUser = DLookup("UserID","TblUsers","Username='" & Me.LoginName & "'")
This will remain available throughout the life of the session.
Now lets say they open a form that displays all the sales made by Jon Smith. The forms RecordSource on an underlying query Called QrySales.
If you then go to the design of the query and bring down the CreatedBy field and in the condition underneath the CreatedBy column enter
=MyCurrentUser()
The query will only display sales for Jon Smith (Pk = 5)
This can be repeated anywhere in the system wher e filtering is required.
There is a more consice example of this in the sample databases section.
Using Public Variables.
David