Hello experts,
I am a VBA newbie. Most of the tricks I apply to my applications I learn
from here or google. I couldn't find a solution for the following two
things, they both are related to using default user preferences. I hope
someone can help me with samples.
Question 1: Keeping filter settings
I have a form with some unbound comboboxes to do some filtering on the
form. For example:
Rowsource of one of the unbound combobox:
SELECT [tblObject].[Object_ID], [tblObject].[Objectname] FROM
[tblObject] UNION (SELECT -1,"All" FROM tblObject);
Further I use the following logic:
---
Private Sub cboObjectLU_Aft erUpdate()
FilterForm
End Sub
---
Private Sub cboObjectLU_Cli ck()
FilterForm
End Sub
---
Private Sub FilterForm()
Dim strFilter As String
strFilter = ""
If Not Me.cboPersonLU = -1 Then
strFilter = "Person_ID = " & Me.cboPersonLU
End If
If Me.cboObjectLU <> -1 Then
If strFilter <> "" Then
strFilter = strFilter & " AND Object_ID = " & Me.cboObjectLU
Else
strFilter = "Object_ID = " & Me.cboObjectLU
End If
End If
Me.Filter = strFilter
Me.FilterOn = True
Me.Requery
End Sub
---
This works great. But what I would like is that the last used filter is
stored in a table and when the form is opened again the last used filter
is applied by default. How should I do that?
Question 2: Use some application defaults
This question is a lot like the first question 1, but what I would like
is to have a form in the application where the user can set some default
values. These values are stored in a table. For example, in this form the
user sets his Person_ID. In other forms this value should be used to set
the default value of a filter, for example as above the unbound combobox
cboPersonLU filter.
Again, I am still a newbie and tried to find tips in this group and
google. I appreciate all help!
Regards,
Suzanne
I am a VBA newbie. Most of the tricks I apply to my applications I learn
from here or google. I couldn't find a solution for the following two
things, they both are related to using default user preferences. I hope
someone can help me with samples.
Question 1: Keeping filter settings
I have a form with some unbound comboboxes to do some filtering on the
form. For example:
Rowsource of one of the unbound combobox:
SELECT [tblObject].[Object_ID], [tblObject].[Objectname] FROM
[tblObject] UNION (SELECT -1,"All" FROM tblObject);
Further I use the following logic:
---
Private Sub cboObjectLU_Aft erUpdate()
FilterForm
End Sub
---
Private Sub cboObjectLU_Cli ck()
FilterForm
End Sub
---
Private Sub FilterForm()
Dim strFilter As String
strFilter = ""
If Not Me.cboPersonLU = -1 Then
strFilter = "Person_ID = " & Me.cboPersonLU
End If
If Me.cboObjectLU <> -1 Then
If strFilter <> "" Then
strFilter = strFilter & " AND Object_ID = " & Me.cboObjectLU
Else
strFilter = "Object_ID = " & Me.cboObjectLU
End If
End If
Me.Filter = strFilter
Me.FilterOn = True
Me.Requery
End Sub
---
This works great. But what I would like is that the last used filter is
stored in a table and when the form is opened again the last used filter
is applied by default. How should I do that?
Question 2: Use some application defaults
This question is a lot like the first question 1, but what I would like
is to have a form in the application where the user can set some default
values. These values are stored in a table. For example, in this form the
user sets his Person_ID. In other forms this value should be used to set
the default value of a filter, for example as above the unbound combobox
cboPersonLU filter.
Again, I am still a newbie and tried to find tips in this group and
google. I appreciate all help!
Regards,
Suzanne