Results 1 to 3 of 3
  1. #1
    sdel_nevo is offline Competent Performer
    Windows 7 32bit Access 2010 32bit
    Join Date
    Apr 2013
    Location
    Gloucester, UK
    Posts
    402

    Disable Button on value of Dcount

    Hi Guys

    for some silly reason i just cant see the wood for the trees with this problem, i have a form called "SignificantEventLogMachineEdit" that has this code on the forms "on Load" event

    'this code counts the number of notes associated with the machine, if the number = 0 then all the report buttons are disabled

    Dim LogCount As String
    LogCount = DCount("CriticalChangeNotesID", "SignificantEventLogNotes", "CriticalChangeMachineID = " & Me.CriticalChangeMachineID)

    If LogCount = 0 Then
    Me.PDFButton.Enabled = False


    Me.PreviewButton.Enabled = False
    Me.PrintButton.Enabled = False
    Me.EMailButton.Enabled = False
    End If

    this works really well, but the problem i cant get my head around is this

    on this form i have a "add Event" button that opens a form called "SignificantEventLogAddEvent" this is a basic form that captures the machineID and notes and stores these in the table "SignificantEventLogNotes".
    what i would like to happen is when this form is closed the code above on the "SignificantEventLogMachineEdit" form runs again so the buttons are now enabled.

    i have tried putting the code into the forms "on Current" "On "activate" and "on open" events but the code does not run. if i shut and then open the form the code runs and the buttons are now enabled.

    any help would be fantastic.

    Steve

  2. #2
    John_G is offline VIP
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2011
    Location
    Ottawa, ON (area)
    Posts
    2,615
    Your problem is that once you set the values to False, you have no way of setting them back to True. You need an "Else" part of the code to set the enabled properities to true if Logcount <> 0.

    If LogCount = 0 then
    ' Set values to False
    Else
    ' Set values to True
    Endif

    Best place for this would be in the On Current event of the form.

  3. #3
    sdel_nevo is offline Competent Performer
    Windows 7 32bit Access 2010 32bit
    Join Date
    Apr 2013
    Location
    Gloucester, UK
    Posts
    402
    Hi John

    omg, many thanks i cant believe i forgot the dam Else statement!!

    many many thanks for your help

    Steve

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

Similar Threads

  1. disable dsum field with button
    By tagteam in forum Access
    Replies: 6
    Last Post: 11-19-2013, 02:25 PM
  2. Enable/Disable Button
    By P.Malius in forum Programming
    Replies: 3
    Last Post: 09-07-2012, 08:36 AM
  3. Disable command button
    By rajulasb in forum Access
    Replies: 2
    Last Post: 08-04-2011, 05:32 AM
  4. Disable App Close button in 2007
    By ajetrumpet in forum Programming
    Replies: 3
    Last Post: 09-05-2010, 11:32 PM
  5. how to disable command button
    By archie in forum Access
    Replies: 1
    Last Post: 08-27-2009, 11:11 PM

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