Results 1 to 3 of 3
  1. #1
    msasan1367 is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Feb 2013
    Posts
    60

    delete button

    see my program, it has part form with delete button
    now I want:
    1- for deleting a part needs to select it, like belown image:
    Click image for larger version. 

Name:	del1.png 
Views:	5 
Size:	10.7 KB 
ID:	11826

    2- if part use in sell form, it can't be deleted and warned


    3- if part can be deleted, give notice "want to delete or not?" if yes then delete itDatabase19.zip

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,626
    1. If you want to save tblPart ID primary key as foreign key in tblSell, need to change the PartID field in tblSell to number type

    2. If you do 1 don't need Part field in tblSell

    3. Create relationship between the two tables that links on the ID and PartID fields, join type "Include all records from tblSell and only those from tblParts that match"

    4. Check 'Enforce Referential Integrity'

    Now if someone tries to delete a part that has been sold, a warning message will pop up and delete won't happen.

    Your form/subform arrangement doesn't really make sense. There is no reason for subform unless you absolutely must have Datasheet View. Can make it a solo form and in Continuous View can arrange controls to look like Datasheet. Delete button in Detail or Header section. Code behind delete button:

    DoCmd.RunCommand acCmdDeleteRecord

    Regardless, binding the main form to table is unnecessary.
    Last edited by June7; 04-04-2013 at 01:52 PM.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    msasan1367 is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Feb 2013
    Posts
    60
    find it:
    Code:
    Forms!blook_masaleh_frm!unit_sub!IDtxt.SetFocus
    Dim delfind, delacc, masID, Eresponse As String
    
    If IsNull(Me.unit_sub.Form.IDtxt) Then
        DoCmd.Beep
    Else
        masID = Me.unit_sub.Form.IDtxt
        delfind = DLookup("masaleh_ID", "blook_tolid_tbl", "masaleh_ID='" & masID & "'")
        If IsNull(delfind) Then
            delacc = MsgBox("delete it?", vbYesNo, "Del")
            If delacc = vbYes Then
                Me.unit_sub.Form.Recordset.Delete
                Me.unit_sub.Form.Recordset.MoveNext
            Else
             Exit Sub
            End If
        Else
            Eresponse = MsgBox("it's been used", vbCritical, "warning")
        End If
    End If

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

Similar Threads

  1. Delete query button?
    By jpalk in forum Queries
    Replies: 2
    Last Post: 10-14-2010, 09:12 AM
  2. Delete button with archive Table
    By tlyons in forum Forms
    Replies: 4
    Last Post: 07-08-2010, 12:18 PM
  3. Button on form to delete all records
    By bbylls in forum Forms
    Replies: 2
    Last Post: 12-08-2009, 12:38 PM
  4. Error while trying to add delete link button.
    By islandboy in forum Access
    Replies: 3
    Last Post: 09-03-2009, 09:32 AM
  5. Add/Delete Button
    By ocemy in forum Forms
    Replies: 1
    Last Post: 03-29-2009, 08:08 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