Results 1 to 4 of 4
  1. #1
    P.Malius is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Jul 2012
    Posts
    10

    Enable/Disable Button

    Hello, I have a form containing a button to approve documents, the button adds a time and date stamp as well as an 'Approved' field in the table once click. I want to make it so that the button can only be clicked once. I have the piece of code to do that, but it won't work, says it cannot find the object. I can't, for the life, of me figure out what is wrong. Someone please help???

    Code:
    Private Sub form_Load()
    If DLookup([Q1ApprovalStatus], [tblCustomerSpecification], Q1ApprovalStatus = "Approved") Then
        Forms![frmSpecification]![Command189].Enabled = True
        Else
        Forms![frmSpecification]![Command189].Enabled = False
        End If
    End Sub


  2. #2
    Missinglinq's Avatar
    Missinglinq is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Location
    Richmond (Virginia, not North Yorkshire!)
    Posts
    3,018
    Your DLookup is malformed! Don't you hate when that happens?

    Should be

    Code:
    If DLookup("Q1ApprovalStatus", "tblCustomerSpecification", "Q1ApprovalStatus = 'Approved' ") Then


    The syntax for Functions with 'Where' clauses varies depending on the Datatype of the Field.

    Linq ;0)>
    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

  3. #3
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,726

  4. #4
    P.Malius is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Jul 2012
    Posts
    10
    Hi, Thanks for the replies. Unfortunate your method did not help me (probably due to my lack of knowledge with Access).

    I have however solved my issue by using the code below with a timer of 1 seconds in the for properties.

    Code:
    Private Sub Form_Timer()
    If Forms!frmSpecification.Q1ApprovalStatus = "Approved" Then
        Forms![frmSpecification]![Command189].Enabled = False
        Else
        Forms![frmSpecification]![Command189].Enabled = True
        End If
    End Sub
    Thanks again for your time

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 3
    Last Post: 08-02-2012, 10:27 AM
  2. Replies: 5
    Last Post: 03-13-2012, 12:28 PM
  3. Enable or Disable Field in Forum
    By lolos66666 in forum Forms
    Replies: 5
    Last Post: 03-13-2011, 05:30 PM
  4. Replies: 1
    Last Post: 02-25-2011, 10:03 AM
  5. Function to Enable/Disable Field
    By swalsh84 in forum Programming
    Replies: 5
    Last Post: 11-04-2010, 02:48 PM

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
  •  
Other Forums: Microsoft Office Forums