Query Criteria from form (1 Viewer)

dongilles

Registered User.
Local time
Today, 04:24
Joined
May 27, 2016
Messages
15
Hello all,

I have a question about Query criteria. Is it possible to use text from a form as criteria. Sorry if this a stupid question I am a real noob with Access.

I have the following:
A login page
After Login the user comes to a homepage
On this homepage are several button and says the loginname
The loginname is created by the loginpage
Futhermore I have a table with data and each row has a field with a loginname attached

Now I want to create a query with the criteria the loginname. Is this possible?
 

bob fitz

AWF VIP
Local time
Today, 12:24
Joined
May 23, 2011
Messages
4,727
Hello all,

I have a question about Query criteria. Is it possible to use text from a form as criteria. Sorry if this a stupid question I am a real noob with Access.

I have the following:
A login page
After Login the user comes to a homepage
On this homepage are several button and says the loginname
The loginname is created by the loginpage
Futhermore I have a table with data and each row has a field with a loginname attached

Now I want to create a query with the criteria the loginname. Is this possible?
Yes it is possible to use a control on a form for the criteria in a query but the form must be open. I don't think it has to be visible, so it could possibly be hidden rather than closed but it must be open.

My preferred way would be to pass the value in the OpenForm command using the OpenArg and retrieve that when the second form opens.
 

Simon_MT

Registered User.
Local time
Today, 12:24
Joined
Feb 26, 2007
Messages
2,177
Try using a Function, all you are doing is adding a filter to the call:

Code:
Function XYZ()
dim loginname as String
    With CodeContextObject
        loginname = .loginname
                DoCmd.OpenReport "XYZ", acViewPreview, , "[loginname] = '" & loginname & "'", acWindowNormal
    End With
End Function
Simon
 

Users who are viewing this thread

Top Bottom