Results 1 to 6 of 6
  1. #1
    Join Date
    Sep 2011
    Posts
    28

    Unanswered: Compile error and Syntax Error

    Hi

    Wonder if anyone can help

    I get an syntax error when compiling the code below.

    Any help will be much apprediated.

    Thanks

    Private Sub Command105_Click()
    If IsNull(Me!Encryption_Password) Then
    Me!Encryption Password = DMin("[Encryption_Password]", "QueryEncryption", "[Encryption_ID]=" & Me!Encryption_Password)
    Debug.Print DMin("[Encryption Password]", "QueryEncryption")

    Debug.Print LaptopID, Me!Encryption_Password

    End If

    End Sub

  2. #2
    Join Date
    Mar 2009
    Posts
    5,442
    Provided Answers: 14
    You cannot use expressions such as:
    Code:
    ...WHERE Something = Null
    or
    Code:
    If Something = Null...
    You try to use the value of Encryption_Password in the criteria parameter of the DMIN() function while it is Null (i.e. has no value). If you try to retrieve the lowest value for Encryption_Password where Encryption_ID is null, it's useless to include it in the criteria as you already know that it is Null. You should use:
    Code:
    Me!Encryption Password = DMin("[Encryption_Password]", "QueryEncryption", "[Encryption_ID] Is Null")
    Have a nice day!

  3. #3
    Join Date
    Sep 2011
    Posts
    28
    Hi Sindho

    Many thanks for your reply

    I have tried your code but when I try to test the code on the form I get an Run Time Error 2001, You cancelled the previous operation.

    There's an option to debug the code. when pressing this option it higlights the code below

    Me!Encrpytion_Password = DMin("[Encryption_Password]", "QueryEncryption", "[Encrpytion_ID] Is Null")


    The code in full is below

    [B]Private Sub Command105_Click()
    If IsNull(Me.Encrpytion_Password) Then
    Me!Encrpytion_Password = DMin("[Encryption_Password]", "QueryEncryption", "[Encrpytion_ID] Is Null")
    Debug.Print DMin("[Encryption Password]", "QueryEncryption")

    Debug.Print LaptopID & ", " & Me!Encrpytion_Password

    End If

    End Sub


    Any help would be much appreciated

    Thanks

  4. #4
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    Im suspicious of
    Code:
    "[Encrpytion_ID] Is Null"
    "IsNULL([Encrpytion_ID])")
    Im also suspicious of returning the minimum value of a column called Encryption_Password. is that column numeric? Im not certain what the return from DMIN will be on a string column

    please provide the DML / SQL for the query QueryEncryption

    I think you need to also think abut whether you use CamelCase, spaces or underscores. In an ideal world you beed to be consistent to make it easier for you and others to read
    I'd rather be riding on the Tiger 800 or the Norton

  5. #5
    Join Date
    Mar 2009
    Posts
    5,442
    Provided Answers: 14
    If there's a column named Encrpytion_ID in QueryEncryption, the syntax of:
    Code:
    "[Encrpytion_ID] Is Null"
    is correct (I checked).

    As healdem says, please provide the SQL for QueryEncryption and also the definition of the table(s) that is uses.
    Have a nice day!

  6. #6
    Join Date
    Aug 2011
    Location
    Indianapolis, IN, USA
    Posts
    41
    This probably applies only to what is on this forum, but it might apply to your code. You have spelled "encryption" wrong in some places.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •