Results 1 to 6 of 6
  1. #1
    Lounger
    Join Date
    Apr 2009
    Posts
    36
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I probably am using the wrong terminology but I have an Orders form with an Orders subform showing line items, like products you can order (basically an invoice). When the user selects a product like a shirt in the combo box and decides he wants to delete that item, I would like the user to be able to do so. Yes, it can be "deselected" or "deleted" right away by pressing ESC, but what if you select an item from the combo box "Products" and then select a quantity and the total gets calculated, etc. and either the user decides to delete an item or comes back to the Order form later and wants to delete an item. I would like to have a delete button appear beside each line when the user has added a product. This way it can easily be deleted. The reason I want to do this is because the user will never be able to go into the tables to delete the items in the Orders subform. I am thinking of every possible way to "dummy proof" the Orders form.

    Any suggestions?

    Thanks,

    Tina

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts
    If your subform uses datasheet view, you cannot have a button in each row - a datasheet displays only data.
    But if the subform is a continuous form, you can place a command button cmdDelete in the detail section. It will be displayed in each record.
    The code for the On Click event of the command button could look like this:

    Code:
    Private Sub cmdDelete_Click()
      On Error Resume Next
      RunCommand acCmdDeleteRecord
    End Sub

  3. #3
    Lounger
    Join Date
    Apr 2009
    Posts
    36
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks Hans,

    I am going to try it right now.

    Tina

  4. #4
    Lounger
    Join Date
    Apr 2009
    Posts
    36
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Hans,

    Thanks so much for this. It worked beautifully.

    I have another question: I have a form of Exhibitors, when I click the "Add an Ordedr" button on the Exhibitors form it opens up and opens up the Exhibitors form so I can add an order for an Exhibitor. I want the form to go to a new record (using DoCmd etc.), then I have the ExhibitorID = CustomerID, this part works beautifully except it does not always give me a new record, it sometimes changes an order I just create. I will give you the code used:

    Private Sub AddRentalOrders_Click()
    On Error GoTo Err_AddRentalOrders_Click

    Dim stDocName As String
    Dim stLinkCriteria As String

    stDocName = "FrmRentalOrders"
    DoCmd.OpenForm stDocName, , , stLinkCriteria
    DoCmd.GoToRecord , , acNewRec
    Forms!FrmRentalOrders.Exhibitor = Me.CompanyID

    Exit_AddRentalOrders_Click:
    Exit Sub

    Err_AddRentalOrders_Click:
    MsgBox Err.Description
    Resume Exit_AddRentalOrders_Click

    End Sub

    Do you know what is wrong?

    Thanks so much,

    Tina

  5. #5
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts
    The code that you posted looks OK. I assume that the Allow Additions property of FrmRentalOrders is set to Yes, otherwise you wouldn't be able to go to a new record.

    Do you have code in the On Open or On Load event of FrmRentalOrders? If so, could it interfere with going to a new record?

    You might try replacing the two lines

    DoCmd.OpenForm stDocName, , , stLinkCriteria
    DoCmd.GoToRecord , , acNewRec

    with

    DoCmd.OpenForm stDocName, , , stLinkCriteria, acFormAdd

  6. #6
    Lounger
    Join Date
    Apr 2009
    Posts
    36
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Hans,

    Thanks yet once again,

    Tina

Posting Permissions

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