Results 1 to 7 of 7
  1. #1
    gangel is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jun 2014
    Posts
    194

    Delete contents of a table field with button!

    Hi pplz,

    I have a button called "add" which adds the parent table/forms ID's batch number (primary key) to the data in a table of the subform

    So
    Master Invoice (Parent)
    - InvID

    Scripts_No_Inv (sub1)
    Private Sub Command9_Click()
    Me.InvBatch = Me.Parent!InvID


    Me.Requery
    Me.Parent.SubInvoiced.Requery


    End Sub



    SubInvoiced (sub2)
    Private Sub Remove_Click()
    Me.InvBatch.Delete
    Me.Requery
    Me.Parent.Scripts_No_Inv.Requery


    End Sub


    So "add" button adds the parent InvID as the InvBatch. This works well and the forms work and the querys re-query. No probs here.

    The "remove" button doesnt work at all All im trying to do is delete the field value (invbatch) that i have just put in.
    .delete is obviously wrong, but ive tried Me.InvBatch = Null which also doesnt work beacuse it thinks im trying to relate the table to a InvID that is null?
    I just need the field "InvBatch" to be empty again

    Sorry ive tried googling HEAPS but still no answer!!!

    Ty for any advice!

  2. #2
    JeffChr is offline Advanced Beginner
    Windows 7 64bit Access 2010 32bit
    Join Date
    Feb 2014
    Posts
    82
    True. You cannot set something to Null because Null is unknown. You say InvID is a primary key, so it is a bound field. Depending on the data type you could set me.InvBatch to "" if it is a string; you could set me.InvBatch to 0 if it is a numeric and then format your field so zero's don't appear.

  3. #3
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    14,605
    You do not DELETE fields, you delete rows in a table.
    For fields you would UPDATE the field to a new value---"" for text , 0 for numeric are typical values.

  4. #4
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    48,712
    A control or field can be set to Null - I do this a lot. I don't allow empty strings in tables.

    However, in this case, it sounds like you need to delete related child record or possibly to cancel entry of a new related record.

    Why are you trying to delete this data after the record is committed to table?
    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.

  5. #5
    gangel is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jun 2014
    Posts
    194
    Hye June (again!)
    So I combined my tables (scripts and invoices) like you said would be smart (and it is).

    Pretty much scripts (table) has these fields:
    Script Date
    Drug
    Quantity
    CustomerID
    InvoiceBatchID

    SO my assistants enter a script (all details except the invoicebatchID)

    We send a claim off for money from an insurance company.

    They send us back a big invoice with out 10-50 scripts on it listed.

    We then look at the invoice and determine which scripts are now paid and how much we got for them.



    SO:
    I created a form (based on my MasterInvoice Table) which is just ID, BatchDate, and BatchValue

    2 subforms are on the sheet,
    One of them lists all uninvoiced items, the other is invoiced items that have the batchID same as the parent form BatchID

    SO i can add invoices from left to right (add the batchID to their record) but if someone makes a mistake and adds the wrong script i want them to be able to remove that batchID from the record so they will go back to being uninvoiced.

  6. #6
    gangel is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jun 2014
    Posts
    194
    figured it out

    Me.InvBatch = "" worked in the end,
    The issue is that i had InvBatch and BatchID (the parent and sub controls) both in the same query and it was messing with it al!! :S

  7. #7
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    48,712
    I don't understand "add invoices from left to right".

    However, if a script ID is incorrectly entered into a textbox, should be able to select the input and hit Delete key.

    If you want a command button then setting textbox to Null should also work.
    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.

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

Similar Threads

  1. Replies: 4
    Last Post: 03-03-2014, 12:47 PM
  2. Replies: 5
    Last Post: 04-18-2012, 12:04 PM
  3. Replies: 3
    Last Post: 05-23-2011, 07:29 AM
  4. Replies: 0
    Last Post: 03-29-2011, 04:11 PM
  5. Delete button with archive Table
    By tlyons in forum Forms
    Replies: 4
    Last Post: 07-08-2010, 12:18 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
  •  
Tech Forums: Microsoft Office Forums