Meena
|
| Posted: 04/15/2002, 5:48 AM |
|
Sir,
I have a problem. I want to display records to the login User related with the user.
I have a Table name "Messages" contains the following fields
Date
Deptt_id
subject
Message
sender
and others...
I have used "Users" table for Login purpose and User_name and Passoword fields for Login Purpose.
this table also have the Deptt_id field which contains the Deptt_id of the user.
I want to display only those records to the Login User which is belongs to the User's Deptt. (i.e. display only those record whose deptt_id is equal to the Deptt_is of the Login User).
For This I have created a Page called "MessageGrid" and Created a UserID variable (of Session type) in this and in Open Event on the Form "Display" of this page I used the following script to extract the Deptt_id of the Login User's :
d_no=dlookup("Users","Deptt_id","user_id=" &Session("UserID"))
which extract the correct d_no of the Login User (The statement Response.write d_no shows the correct Deptt_no (Number)).
When I used this d_no variable in the SQL string as follows :
select * form Messages where Messages.Deptt_id=d_no
This gives the following error Message when running the generated page :
Microsoft OLE DB Provider for ODBC Drivers error '80040e10'
[Microsoft][ODBC Microsoft Access Driver] Too few parameters. Expected 1.
/Meena/Common.asp, line 43
What is the Problem? I think the value of the d_no is NOT passed to the SQL statement.
How Can I do this. Please Help Me.
Meena
|
|
|
 |
CodeCharge Support
|
| Posted: 04/15/2002, 6:32 AM |
|
Meena,
try to built custom Where clause for sql query. Use custom sql for the form or add the fields you want to list. Then in Open event of the form look up Deptt_id corresponding to logged in user and use it to built WHERE clause. E.g.:
d_no=dlookup("Users","Deptt_id","user_id=" &Session("UserID"))
if sWhere = "" then
sWhere = " WHERE Messages.Deptt_id=" & ToSQL(d_no, "Number")
else
sWhere = " AND Messages.Deptt_id=" & ToSQL(d_no, "Number")
end if
|
|
|
 |
|