Error using GUID in SQL string for Domain Fuctions and dbs.OpenRecordset 
Author Message
 Error using GUID in SQL string for Domain Fuctions and dbs.OpenRecordset

Hi, all.  I'm a fledgling Access developer having problems.

The problem lies in the line used to select the recordset for rstGroup
(toward the end of this snippet).
I get "Error 3075: Syntax error in querry expression 'fldUser =
[unrecognizable character]'"

I'm sure it has to do with using GUID as PK  (Is this a good or bad idea?).
The code worked fine before I started modifying to accomdate GUID, but I'm
stuck at this particular hurdle.  How do I properly write this type of code?
Any suggestions on concise reading material?

In code:

Private Function sLogin()
On Error GoTo ErrHandler

    Dim bolClose As Boolean
    Dim dbs As Database
    Dim rstUser As Recordset
    Dim rstGroup As Recordset
    Dim rstLoggedIn As Recordset
    Dim sUser As String
    Dim sGroup As String
    Dim sSession As String
    Dim sPassword As String
    Dim sProfile As String
    Dim sForm As String
    Dim nCount As Integer
    Dim idx As Integer
    Dim bolValid As Boolean

    bolClose = False
    bolValid = False
    Set dbs = CurrentDb
    Set rstUser = dbs.OpenRecordset("SELECT * FROM qryUser " & _
        "WHERE fldLogin = '" & Me.txtLogin & "'")
    If rstUser.EOF Then
        MsgBox "User login name not found.", , "Security Notice #1"
        GoTo ExitParagraph
    Else
        sUser = StringFromGUID(rstUser!fldID)
        Forms!frmSession!txtThisUser = sUser
        sPassword = rstUser!fldPassword
    End If
    If (sPassword <> Me.txtPassword) Then
        MsgBox "Password invalid for this user.", , "Security Notice #2"
        GoTo ExitParagraph
    End If
    Set rstGroup = dbs.OpenRecordset("SELECT * FROM qryUserGroup " & _
        "WHERE fldUser = " & GUIDFromString(sUser))
    If rstGroup.EOF Then
        MsgBox "Unable to access group membership listings.", , _
            "Security Notice #3"
        GoTo ExitParagraph
    Else ....



Fri, 02 Feb 2001 03:00:00 GMT  
 Error using GUID in SQL string for Domain Fuctions and dbs.OpenRecordset


Quote:
>Set rstGroup = dbs.OpenRecordset("SELECT * FROM qryUserGroup " & _
>        "WHERE fldUser = " & GUIDFromString(sUser))

If GUIDFromString() returns a string, it'll need delimiting with quote
marks. As I understand, a GUID is too big to go into a long integer.

Try
  "WHERE fldUser = """ & GUIDFromString(sUser))  & """;"

Tim F

--



Sun, 04 Feb 2001 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. How to convert a GUID string to a GUID data type

2. Openrecordset whith Sql string as source

3. Max. length of SQL string in openrecordset statement

4. Openrecordset and SQL string?

5. Using a GUID as a Primary Key or indexing a GUID

6. Run time error 3622: OpenRecordSet: SQL server table: IDENTITY column

7. "OpenRecordset" using sql

8. OpenRecordset using sql queries

9. Problem with OpenRecordset used along with a SQL query

10. Why ISAM error using Access and unbound ADO controls with sql string connection

11. domain pruefen domain provider es domain registrieren domain angebot no domain

12. Getting an error using OpenRecordSet to open a query

 

 
Powered by phpBB® Forum Software