Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Filter Question

Status
Not open for further replies.

avagodro

Technical User
Aug 12, 2005
83
US
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?
 
firstly, you do realise that there is a "CurrentUser" keyword right?

secondly, I'm assuming your username is a string value, so where are your string delimiters?

--------------------
Procrastinate Now!
 
I am not using the built in security funtions. I know that it is more secure, but was wanting a little flexibility in the log in form.
 
then may I suggest you have a global variable in a module which gets initialised to the username, instead of using a text file...

--------------------
Procrastinate Now!
 
I am actually not wanting to do that right now, as it would require a major rewrite of the entire database.
I am simply looking to see if a filter can be set on a TextBox on open to a string variable: m_strUser
 
You may try this:[tt]
Me.Filter = "User_Name='" & m_strUser & "'"[/tt]

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top