We were all novices once.
Once you start getting into limiting data access to users then you need to have a way of marking in your database what data to display for what users. So for example if user (id = a) can only view records 1, 3, 4, 5 then you need to mark those records as being accessable to user (id = a)... which I think you have done with the [leadofficer] field. So what your looking to do is filter the records based on this field and display the results in a combo box.
There is an easier method to do this that borrows from duckthings recommendation.
A combo box in Access has a RowSource property that you can set to a query or SQL statement. In duckthing's recommendation he fills a recordset with records from the following query/SQL statement.
SELECT [company_name] FROM [tblcompany] WHERE [leadofficer] = '" & login_name & "'"
If you set the RowSource property of the combo box to this statement then the combo box will display the filtered records that match the login_name i.e. user (a). Where you do this depends on when you want the information available. It's likely you want the data available when the form first opens. So in the Form_Load event place the following...
Me.MyCombo.RowSourceType = "Table/Query"
Me.MyCombo.RowSource = "SELECT [company_name] FROM [tblCompany] WHERE [leadofficer] = '" & login_name & "'"
Where login_name is your global variable containing the user ID.
|