Results 1 to 13 of 13
  1. #1
    Join Date
    May 2006
    Posts
    386

    Unanswered: Urgent Help Needed PLEASE! I get this error " Method or Data member not found

    I am trying to protect my database by entering the PCs serial number and pc name on the Open Event of my main form, I have the correct spelling for the unbound text box as TxtPc and I have the same spealling in the code on the Open Event Procedure as bellow:

    Private Sub Form_Open(Cancel As Integer)

    If Me.TxtPc => "MichaelJones" And Me.TxtSrlNo = "-85658452250" Then
    MsgBox "Sorry, you have no access to this db ", vbCritical, "Admin"
    DoCmd.Quit acQuitSaveNone
    Else
    End If
    End Sub
    for some reason when i run the database i get this message " Compile Error "Method or data member not found" I would be most grateful if someone could help me as it is middle of the night and I am stuck in here and can't do anything.
    Thank you for your help.
    Emi-UK
    Love begets Love, Help Begets Help

  2. #2
    Join Date
    Nov 2007
    Location
    Adelaide, South Australia
    Posts
    4,049
    Apart from checking that your form has an object called TxtPc and an object called TxtSrlNo, the only thing I can see here is a superfluous > sign just before "MichaelJones".
    Owner and Manager of
    CypherBYTE, Microsoft Access Development Specialists.
    Microsoft Access MCP.
    And all around nice guy!


    "Heck it's something understood by accountants ... so it can't be 'that' difficult..." -- Healdem
    "...teach a man to code and he'll be frustrated for life! " -- georgev

  3. #3
    Join Date
    Dec 2002
    Location
    Préverenges, Switzerland
    Posts
    3,740
    try
    >=
    if that is what you want.
    => does not work

    izy
    currently using SS 2008R2

  4. #4
    Join Date
    May 2006
    Posts
    386
    Sorry, this is the write code:
    Private Sub Form_Open(Cancel As Integer)
    If Me.txtPc = "MichaelJones" And Me.TxtSrlNo = "-4525454800" Then
    MsgBox "Sorry, you have no accesss to this db", vbCritical, "Admin"
    DoCmd.Quit acQuitSaveNone
    Else
    End If

    End Sub
    I basically want this code to only run on computers that their serial numbe and pc name is equal to whatever is in the code. I have also created the module that has this code:
    Option Compare Database
    Option Explicit

    Private Declare Function GetComputerName Lib "kernel32" Alias _
    "GetComputerNameA" (ByVal lpBuffer As String, nSize As Long) As Long

    Function ComputerName() As String
    ' Returns the name of the local computer.
    Dim BUFFER As String * 512, Length As Long
    Length = Len(BUFFER)
    If GetComputerName(BUFFER, Length) Then
    ' this API returns non-zero if successful,
    ' and modifies the length argument
    ComputerName = Left(BUFFER, Length)
    End If
    End Function
    I am still getting the same error despite the fact that there is no spelling mistake on the unbound textbox.

    I would really appreciate your assistance.
    Emi-UK
    Love begets Love, Help Begets Help

  5. #5
    Join Date
    Apr 2004
    Location
    Derbyshire, UK
    Posts
    789
    Provided Answers: 1
    Hi

    Which line has the compile error?

    MTB

  6. #6
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    I'd remove the me. and see what happens
    ideally you need to identify which line is reporting the error

    mind you Id also considere moving the process to a table rather than hard coding this.
    I'd rather be riding on the Tiger 800 or the Norton

  7. #7
    Join Date
    May 2008
    Location
    Raleigh, NC
    Posts
    151
    Is it safe to assume that if you take out this code, the app runs fine?
    --If its free, take it for what its worth!

  8. #8
    Join Date
    May 2006
    Posts
    386
    Hi, Thank you for all your responses.
    I am getting the error on this line
    If Me.txtPc = "MichaelJones" And Me.TxtSrlNo = "-4525454800" Then
    I think Me. should remain as it is referring to a unbound text box that has the pct name. However, i tried removing it as well and gave me different error.

    To be honest, I dont know how to move the process in a table.

    Msg to: stuschmied: we need the code to run so that the db wont run on every computer.

    I would really appreciate your help.
    Emi-UK
    Love begets Love, Help Begets Help

  9. #9
    Join Date
    Apr 2004
    Location
    Derbyshire, UK
    Posts
    789
    Provided Answers: 1
    unbound text box that has the pct name
    Should
    TxtPc
    be
    TxtPct
    ??

    If you remove Me. then the compile error would be "Varible not defined" ??


    MTB

  10. #10
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10
    Have you tried?
    Code:
    Me.textboxname.Value
    George
    Home | Blog

  11. #11
    Join Date
    May 2008
    Location
    Raleigh, NC
    Posts
    151
    Hi Emi,

    If you comment out the entire on open routine, does the form open OK? If not then the problem is elsewhere. Sometimes Access hiccups at certain spots due to unrelated problems. I one time got a compile error on the mid() function due to a missing mde file in the references. The mde had nothing to do with the function, its just where it surfaced. Check your references and make sure the form opens if you comment out the name and sn check.

    :-)Stu
    --If its free, take it for what its worth!

  12. #12
    Join Date
    Nov 2007
    Location
    Adelaide, South Australia
    Posts
    4,049
    If Me.txtPc = "MichaelJones" And Me.TxtSrlNo = "-4525454800" Then
    When it goes into debug mode on this line, you can point your mouse to Me.txtPc and Me.TxtSrlNo to examine what the values are. At least one of them will show the error.

    If one or either of them show the error, you need to triple check that you have textboxes on your form with the exact same name as specified.
    Owner and Manager of
    CypherBYTE, Microsoft Access Development Specialists.
    Microsoft Access MCP.
    And all around nice guy!


    "Heck it's something understood by accountants ... so it can't be 'that' difficult..." -- Healdem
    "...teach a man to code and he'll be frustrated for life! " -- georgev

  13. #13
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    what happnes if you change
    If Me.txtPc = "MichaelJones" And Me.TxtSrlNo = "-4525454800" Then
    to
    If Me.TXTPC = "MichaelJones" And Me.TXTSRLNO = "-4525454800" Then

    if the capitalisaiton changes then it shows the the IDE is recognising the control names
    if it doenst then the one that hasn't changed is the problem, go back and check what you actually called the control


    mind you you are doing this as part of hte forms on open event.... wonder if the controls actually exist at the time the form open event is called?
    even if they do, how do you propose to get the values loaded

    a more appropriate event may be the on activate event

    I still think its a pants way of doing security
    I'd rather be riding on the Tiger 800 or the Norton

Posting Permissions

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