Sherri
|
| Posted: 09/08/2004, 10:35 AM |
|
I am having trouble getting the following to work:
When a user logs in, I only want them to see records in a grid that correspond to their UID. I've put the following statement into the BeforeShow event of the grid, but I get an error that says "expected (case)." Can you help? Thanks!
Select * from [T-PayStubs] where UID=session.userlogin
I've put a debug in, and a session.userlogin is coming up as 'vsv', which equals a an entry in the UID field of my T-PayStubs table.
Thanks!
|
|
|
 |
dataobjx
Posts: 181
|
| Posted: 09/08/2004, 11:49 AM |
|
Sherri,
It's difficult to understand where the error is based on the information you've provided. Need just a bit more clarification.
Show us like this;
Dim SQL
Dim lngID
lngID = Session("UserID")
SQL = "Select * From [T-PayStubs] Where UID=" & lngID
If you're doing this.... it's in the wrong place/event.
1) you should do this from the DataGrid DataSource Where Clause section (add this by hitting the + key for the where clause) OR
2) you would add the where clause programmatically in the "Before_Build_Select" event for the grid.
e.g,
Function Before_Build_Select()
Dim SQL
Dim lngID
lngID = Session("UserID")
SQL = " UID=" & lngID
If MyDataSource.Datasource.Where = EMPTY Then
MyDataSource.Datasource.Where = SQL
Else
MyDataSource.Datasource.Where = " AND " & SQL
End If
End Function
Hope this helps, if not send a bit more info so we can zero in on the issue.
_________________
www.DataObjx.net
www.mydigitalapps.com |
 |
 |
Sherri
|
| Posted: 09/08/2004, 12:36 PM |
|
Thank you - I'm getting close, but not quite there. Here is more information. I hope this helps you to give me more details. Thanks!
----------
Here is what is set for the Before_Build_Select of the Grid:
======================================================
Function T_PayStubs1_DataSource_BeforeBuildSelect() 'T_PayStubs1_DataSource_BeforeBuildSelect @10-CD7254DA
'Custom Code @29-73254650
' -------------------------
Dim SQL
Dim lngID
lngID = Session("UserLogin")
SQL = " UID=" & lngID
If T_PayStubs1.Datasource.Where = EMPTY Then
T_PayStubs1.Datasource.Where = SQL
Else
T_PayStubs1.Datasource.Where = " AND " & SQL
End If
' -------------------------
'End Custom Code
End Function 'Close T_PayStubs1_DataSource_BeforeBuildSelect @10-54C34B28
======================================================
Here is the error I receive on my page, from the above code:
======================================================
Form: Grid T_PayStubs1
Error: Syntax error (missing operator) in query expression 'UID=2la'. (Microsoft JET Database Engine)
======================================================
In the above error, I'm loggin in with an UserLogin of 2la, and this exists in the UID field of my table in the Access database.
|
|
|
 |
Tuong Do
|
| Posted: 11/10/2004, 6:08 PM |
|
Replace
SQL = " UID=" & lngID
With
SQL = " UID=" & CCToSQL(lngID, "Text")
"Sherri" <Sherri@forum.codecharge> wrote in message
news:2413f5f2ccbaf2@news.codecharge.com...
> Thank you - I'm getting close, but not quite there. Here is more
> information.
> I hope this helps you to give me more details. Thanks!
> ----------
> Here is what is set for the Before_Build_Select of the Grid:
> ======================================================
> Function T_PayStubs1_DataSource_BeforeBuildSelect()
> 'T_PayStubs1_DataSource_BeforeBuildSelect @10-CD7254DA
>
> 'Custom Code @29-73254650
> ' -------------------------
> Dim SQL
> Dim lngID
> lngID = Session("UserLogin")
> SQL = " UID=" & lngID
>
> If T_PayStubs1.Datasource.Where = EMPTY Then
> T_PayStubs1.Datasource.Where = SQL
> Else
> T_PayStubs1.Datasource.Where = " AND " & SQL
> End If
> ' -------------------------
> 'End Custom Code
>
> End Function 'Close T_PayStubs1_DataSource_BeforeBuildSelect @10-54C34B28
> ======================================================
> Here is the error I receive on my page, from the above code:
> ======================================================
> Form: Grid T_PayStubs1
> Error: Syntax error (missing operator) in query expression 'UID=2la'.
> (Microsoft JET Database Engine)
> ======================================================
> In the above error, I'm loggin in with an UserLogin of 2la, and this
> exists in
> the UID field of my table in the Access database.
>
> ---------------------------------------
> Sent from YesSoftware forum
> http://forums.codecharge.com/
>
|
|
|
 |
|