Results 1 to 2 of 2
  1. #1
    nabiki is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Jul 2012
    Posts
    2

    how to clear fields after submit

    I have a DB that is used to bring up client information as contact info for clients, after they use that info to ring client i need them to save a record of activity.

    So my form has one page/tab with field to add new records to latest contact activity to a table.
    I then have the next tab that shows that same table as "previous records"
    problem is when i hit submit - the data saves to the table (sometimes twice because i hit submit twice), the form fields just contain the same info and the submitted data is not shown in the subquery on the next page...

    Is there a way i can have the data save but then the fields are cleared, rerun the subform query (QRY - Fee Inclusions Subform) and move to the next page/tab

    here is the code i have as onclick event procedure
    Private Sub Command78_Click()
    Dim rst As New ADODB.Recordset
    rst.Open "activity", CurrentProject.Connection, adOpenKeyset, adLockPessimistic
    With rst
    .AddNew
    !code = Me.code
    !Activity = Me.Activity
    !Typeofactivity = Me.activitytype
    !Date = Me.Date1
    .Update


    .Close
    End With
    Set rst = Nothing
    End Sub

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,624
    Why not use a bound form? Reduces chance of duplicate record, no need for the 'Submit' code. Existing records can be displayed on the same form as new record entry. You might like the Split Form introduced with Access 2007.

    With unbound form will need to set each control to null to 'clear' the form or close then open form.
    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. Macro to add and clear fields
    By Skroof in forum Access
    Replies: 1
    Last Post: 05-14-2012, 01:13 PM
  2. Clear some fields and not others
    By funkygoorilla in forum Access
    Replies: 12
    Last Post: 08-23-2011, 07:38 AM
  3. Form Fields Clear
    By rajulasb in forum Access
    Replies: 1
    Last Post: 08-06-2011, 01:11 AM
  4. Clear fields in a record
    By stryder09 in forum Access
    Replies: 9
    Last Post: 05-12-2011, 01:34 PM
  5. OnClick Event submit and clear
    By Desstro in forum Forms
    Replies: 1
    Last Post: 01-12-2011, 09:42 AM

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