Filter Question

  • Thread starter Thread starter spokane29 via AccessMonster.com
  • Start date Start date
S

spokane29 via AccessMonster.com

I have a form in which I would like to apply a filter on open. I know that
this can be added using the On Open event, as I want to do it in code. Where
I am having the problem is this:
I have a log in process set to database. Upon successful login, it stores the
username in a temporary file (which is erased on exit). It stores the data as:

[Identifier]
User=
Security=
etc.

I want to be able to pull the user data and apply it to a TextBox field on
open.
The TextBox that I want to apply the filter is named User_Name.

I have tried the following:

Dim m_strUser As String

Private Sub Form_Open()
m_strUser = INIGetSettingString("test", "User", g_cstrFilePath)
Me.Filter = "User_Name = " & m_strUser
Me.FilterOn = True

End Sub

This is pulling the User Name from the file as it should but it is not
applying the filter correctly. Instead I am getting the popup, similar to
what you would get with a Parameter Query.
Any suggestions?
 
spokane29 said:
Me.Filter = "User_Name = " & m_strUser

You need quotes around the user name value. Cut & paste the following
new line. Do not try to type it manually.

Me.Filter = "User_Name = """ & m_strUser & """"

HTH,
TC [MVP Access]
 
Back
Top