Controlling a subform using controls on a form

Locopete99

Registered User.
Local time
Yesterday, 23:04
Joined
Jul 11, 2016
Messages
163
Hi All,

I'm designing a database to keep track of improvements on orders.

I want the "user area" form to have a subform showing all their improvement requests.

I want this to be set by controls on a form.

1) The records will always be linked by the Username to make sure they only see their own improvements.
2) I then have 3 other controls that I want to be able to filter by. Reference, Replied and completed.

Replied and completed are Yes/No tick boxes, but this is always showing the first record, whether this matches the criteria or not.

I have attached a picture of the early stages of my development.

Can someone point me into how best to do what Im trying to do?

If needed I'm on Access 2010
 

Attachments

  • Form and subform.PNG
    Form and subform.PNG
    26.6 KB · Views: 112
What you can do is find out the user when opening the form. And then use this user to query the data

Private Sub Form_Open(Cancel As Integer)
Dim UserName as string
Dim SQLstr as string

UserName = Environ$("username")
' Make the query. Be aware of the ' sign between the double quotes because ' Username is a string

SQLstr = “SELECT * from YOURTABLE where user = ‘“ & Username & “’”
' query now the data in your subform
Me.”YouSubform”.Form.RecordSource = SQLstr

End sub
 

Users who are viewing this thread

Back
Top Bottom