Welcome to SPN

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

Sign Up Now!

Enable/Disable Button on DS Subform Record Selection, HELP?

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

  1. niuginikiwi

    niuginikiwi
    Expand Collapse
    Guest

    Hi all,
    I have three delete buttons on main form that I would like to have them sit
    of on top of each other.

    I have 2 subforms in Datasheet view on a main form. Btn1 for deleting the
    whole record on the form, Btn2 for delecting a selected/higlighted record in
    the first subform and finally Btn3 for deleting a selected record in the
    sencond subform. I have figured out a way to Delete the Selected Record using
    their respective buttons.
    Eg: first button has got this SQL string to delete straight from table and
    that works..

    But what I want to do is to have appropirate buttons being either enabled or
    visible when a record is selected in a respective subform of if none is
    selected then, the Btn1 which does the whole delete should be enabled/visible.
    I used the on current Event off all the 3 forms with the code below but its
    im not getting the hehaviour I want...

    Me.Parent!btnDeletePlantingDetails.Enabled = True
    Me.Parent!btnDeletePlanting.Enabled = False
    Me.Parent!btnDeleteFertDetails.Enabled = False

    I just want the respective button to show up when i select a record to be
    deleted on a subform on a certain subform...

    Thanks for any help
     
  2. Loading...

    Similar Threads Forum Date
    Should SPN Keep the 'Like' Button? SPN Poll Hard Talk May 17, 2013

  3. Wolfgang Kais

    Wolfgang Kais
    Expand Collapse
    Guest

    Hello "niuginikiwi".

    "niuginikiwi" wrote:
    > Hi all,
    > I have three delete buttons on main form that I would like to have
    > them sit of on top of each other.
    >
    > I have 2 subforms in Datasheet view on a main form. Btn1 for
    > deleting the whole record on the form, Btn2 for delecting a
    > selected/higlighted record in the first subform and finally Btn3
    > for deleting a selected record in the sencond subform. I have
    > figured out a way to Delete the Selected Record using their
    > respective buttons.
    > Eg: first button has got this SQL string to delete straight from
    > table and that works..


    How about a single delete button and
    On Error Resume Next
    Screen.PreviosControl.SetFocus
    RunCommand acCmdDeleteRecord

    > But what I want to do is to have appropirate buttons being either
    > enabled or visible when a record is selected in a respective subform
    > of if none is selected then, the Btn1 which does the whole delete
    > should be enabled/visible. I used the on current Event off all the 3
    > forms with the code below but its im not getting the hehaviour I want...
    >
    > Me.Parent!btnDeletePlantingDetails.Enabled = True
    > Me.Parent!btnDeletePlanting.Enabled = False
    > Me.Parent!btnDeleteFertDetails.Enabled = False


    The last subforms delete button will be enabled although the focus
    sits in the main form.

    > I just want the respective button to show up when i select a record
    > to be deleted on a subform on a certain subform...


    You do not have to write code in the subforms to achieve this.
    In design view, enable btnDeletePlanting and disable the other two.
    Write code for the Enter and Exit events of the two subform
    controls in the main form (I assumed that the names of these
    controls are fsubPlantingDetails and fsubFertDetails):

    Private Sub fsubPlantingDetails_Enter()
    Me.btnDeletePlanting.Enabled = False
    Me.btnDeletePlantingDetails.Enabled = True
    End Sub

    Private Sub fsubPlantingDetails_Exit(Cancel As Integer)
    Me.btnDeletePlantingDetails.Enabled = False
    Me.btnDeletePlanting.Enabled = True
    End Sub

    Private Sub fsubFertDetails_Enter()
    Me.btnDeletePlanting.Enabled = False
    Me.btnDeleteFertDetails.Enabled = True
    End Sub

    Private Sub fsubFertDetails_Exit(Cancel As Integer)
    Me.btnDeleteFertDetails.Enabled = False
    Me.btnDeletePlanting.Enabled = True
    End Sub

    --
    Regards,
    Wolfgang
     
  4. niuginikiwi

    niuginikiwi
    Expand Collapse
    Guest

    Thanks Wolfgang,
    I preferred your first option which is having the one button to do all with
    the piece of code you gave me sorted me out exactly with what I was looking
    for....
    Thanks so much

    "Wolfgang Kais" wrote:

    > Hello "niuginikiwi".
    >
    > "niuginikiwi" wrote:
    > > Hi all,
    > > I have three delete buttons on main form that I would like to have
    > > them sit of on top of each other.
    > >
    > > I have 2 subforms in Datasheet view on a main form. Btn1 for
    > > deleting the whole record on the form, Btn2 for delecting a
    > > selected/higlighted record in the first subform and finally Btn3
    > > for deleting a selected record in the sencond subform. I have
    > > figured out a way to Delete the Selected Record using their
    > > respective buttons.
    > > Eg: first button has got this SQL string to delete straight from
    > > table and that works..

    >
    > How about a single delete button and
    > On Error Resume Next
    > Screen.PreviosControl.SetFocus
    > RunCommand acCmdDeleteRecord
    >
    > > But what I want to do is to have appropirate buttons being either
    > > enabled or visible when a record is selected in a respective subform
    > > of if none is selected then, the Btn1 which does the whole delete
    > > should be enabled/visible. I used the on current Event off all the 3
    > > forms with the code below but its im not getting the hehaviour I want...
    > >
    > > Me.Parent!btnDeletePlantingDetails.Enabled = True
    > > Me.Parent!btnDeletePlanting.Enabled = False
    > > Me.Parent!btnDeleteFertDetails.Enabled = False

    >
    > The last subforms delete button will be enabled although the focus
    > sits in the main form.
    >
    > > I just want the respective button to show up when i select a record
    > > to be deleted on a subform on a certain subform...

    >
    > You do not have to write code in the subforms to achieve this.
    > In design view, enable btnDeletePlanting and disable the other two.
    > Write code for the Enter and Exit events of the two subform
    > controls in the main form (I assumed that the names of these
    > controls are fsubPlantingDetails and fsubFertDetails):
    >
    > Private Sub fsubPlantingDetails_Enter()
    > Me.btnDeletePlanting.Enabled = False
    > Me.btnDeletePlantingDetails.Enabled = True
    > End Sub
    >
    > Private Sub fsubPlantingDetails_Exit(Cancel As Integer)
    > Me.btnDeletePlantingDetails.Enabled = False
    > Me.btnDeletePlanting.Enabled = True
    > End Sub
    >
    > Private Sub fsubFertDetails_Enter()
    > Me.btnDeletePlanting.Enabled = False
    > Me.btnDeleteFertDetails.Enabled = True
    > End Sub
    >
    > Private Sub fsubFertDetails_Exit(Cancel As Integer)
    > Me.btnDeleteFertDetails.Enabled = False
    > Me.btnDeletePlanting.Enabled = True
    > End Sub
    >
    > --
    > Regards,
    > Wolfgang
    >
    >
    >
     

Share This Page