Link to home
Start Free TrialLog in
Avatar of drtopserv
drtopservFlag for Israel

asked on

Open a Continuous Form with querying specific field(username)

Hi,
I have build a Continuous Form , I put an Unbound control that can retrieve a username from a username table, i have already a field in a Continuous Form that contain a username.
what i need is to on open a Continuous Form to list me the records that related that the username who opened the Continuous Form.
when i created a query for that Continuous Form, and use :
[forms]![ContinuousFormName].txtusername
doesn`t help me out, it`s result is empty rows.
Avatar of Bill Ross
Bill Ross
Flag of United States of America image

Hi,

How are you finding out the user name when a user uses the form?

Bill
Avatar of drtopserv

ASKER

I just found there is the problem,but still need help.
the form i`m trying to open is a Continuous Form, and i put the query in the record source of the form.
when i try to open the form, it seeks for the value of the txtusername and found it empty then it pop-up window asking me to put a value for the txtusername,then it works.
it means that i`m asking to filter the form recordsource depend of txtusername that still have no-value , which is not good.
how can i solve that, that the Continuous Form will first check whois accessing the form and filter rows depend on the username?
Oh, guy i have solve it by using
'This function is used to allow the use of the Environ function in Access 2003
   
Public Function Environ(Expression)
On Error GoTo Err_Environ
       
    Environ = VBA.Environ(Expression)
   
Exit_Environ:
    Exit Function
   
Err_Environ:
    MsgBox Err.Number & " - " & Err.Description
    Resume Exit_Environ
   
End Function

and use the function : environ=("username") in the query of the record source.
and it works:}
if somebody have better way i`ll be glad to hear  :}
ASKER CERTIFIED SOLUTION
Avatar of Bill Ross
Bill Ross
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
using  environ("Username") in a query not working without the user of (Environ = VBA.Environ(Expression)

must user the vba.environ to work (not environ) alone.
Hi,

Post the SQL of your query and I'll show you how.

Regards,

Bill
BillDenver, thnx alot, YOUR comments helps me to solve the problem,which was to expand all the subforms on open event, then the code works fine.
thnx ALOT.

btw, i have a new Q posted about the same file, but related to deletion recordset, I hope you have a little time to review the Q , (thnx in regard:})
HI,

What is the question ID and I'll try to help.

Bill
WOW,Thnx alot man, here is the ID: 28190365
Did you check the Q?
Yes.  Please close this Q if it's been answered.
thnx alot,works for me