Welcome to SPN

Register and Join the most happening forum of Sikh community & intellectuals from around the world.

Sign Up Now!

broken code?

Discussion in 'Information Technology' started by - Alex, Jul 28, 2006.

Tags:
  1. - Alex

    - Alex
    Expand Collapse
    Guest

    This is the oddest thing I've ever run into in my short 3 years of coding, so
    take a look if you've run into this in Access before any help would be
    appreciated exponentally.

    the Code :

    Private Sub Form_Current()
    If Me.CurrentRecord = 1 Then
    Me.btnSubFormPreviousRecord.Enabled = False
    Else
    Me.btnSubFormPreviousRecord.Enabled = True
    End If

    If Me.Recordset.RecordCount < 1 Then
    Me.btnAddNewItem.Enabled = False
    Else
    Me.btnAddNewItem.Enabled = True
    End If

    If Me.CurrentRecord = Me.Recordset.RecordCount Or
    Me.Recordset.RecordCount < 1 Then
    Me.btnSubFormNextRecord.Enabled = False
    Else
    Me.btnSubFormNextRecord.Enabled = True
    End If
    End Sub

    'and in a subform to that form

    Private Sub Form_Current()
    If Me.Recordset.AbsolutePosition + 1 = Me.Recordset.RecordCount Then
    Me.btnMainFormNext.Enabled = False
    Else
    Me.btnMainFormNext.Enabled = True
    End If

    If Me.CurrentRecord = 1 Then
    Me.btnMainFrmPrevious.Enabled = False
    Else
    Me.btnMainFrmPrevious.Enabled = True
    End If
    End Sub

    The Program :

    Main form holds a set of records and has a manually created next record and
    previous record button that shift the subform records in the regular manner.
    The subform has a next, previous, and new record button. the new record
    button should be disabled when there are no records, the next and previously
    act normally.

    The Complication :

    The code is solid were that the probelm this would be simple. Everytime I
    start the main form, both buttons are Disabled, even though there are 14
    records on the main form, and all three buttons on the sub form are disabled
    even though theres a multitude of records on that one. Once I am able to for
    the records to move manually (say, roll the mouse button) then it works fine,
    except the subform that disables both once I move tha main form again. Now
    heres where it get freaky.

    When I break, and step threw the code, line by line, it works fine, all the
    right buttons (in the case of the open main form the next button) are
    enabled. but as soon as I stop breaking threw the code again it breaks, once
    more. The Kicker? my boss suggests that i delete and recode, so I do, it
    work for about 2 start-ups then breaks again. I just have no idea why or how
    this is doing this, if anyone has any solutions, ideas, leads, anything to go
    on, I wouold be in your debt.

    If this helps :

    When I step threw the code in the form_Current event of the subform it runs
    anywhere from 1 to 4 times when I change the main form.

    - Alex
     
  2. Loading...

    Similar Threads Forum Date
    Sikhi Sachiara - Whom All Have Broken The Wall Of Falsehood? Sikh Sikhi Sikhism Apr 3, 2016
    Self On Being, Broken Blogs Mar 9, 2016
    The Broken Circle Inspirational Stories May 6, 2013
    Judaism Night of Broken Glass (today is the anniversary of it) Interfaith Dialogues Nov 10, 2012
    UK Yasmin Alibhai-Brown: Asian men, white women and a taboo that must be broken Breaking News Nov 30, 2010

Share This Page