Results 1 to 2 of 2
  1. #1
    octsim is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Oct 2013
    Posts
    15

    Problems adding a new entry

    Hey there,

    I'm having problems with my data entry form and a button that performs simple VBA code. What I want is a button that saves the record, jumps back to the first tab of a tab control item, clears all the data and and adds a new entry.
    I have used this:
    Code:
    Private Sub SaveBtn_Click()
    If base_data = True And vacc_data = True And si_data = True And form_data = True Then
    On Error Resume Next
    DoCmd.RunCommand accCmdSaveRecord
    DoCmd.RunCommand accCmdRecordsGoToNew
    Me.tabctrl_main.Pages(0).SetFocus
    base_data = False
    vacc_data = False
    si_data = False
    form_data = False
    Else
    MsgBox ("Please enter all required data!")
    End If
    The boolean variables base_data .. etc. are set to true after pressing next on the first, second and so on tab in order to make sure that all data has been entered. The command does save records but does not clear all the text boxes and does not add a new entry in order to proceed and enter the next one.
    What am I missing?
    Should I also change the error handling to a message box in case the saving has been cancelled? Is there any way to get a message box to pop up in case the data has been successfully saved?

    Thanks in advance!

    Octavio

  2. #2
    SoftwareMatters is offline Access VBA Developers
    Windows 7 64bit Access 2003
    Join Date
    Mar 2009
    Location
    Dorset
    Posts
    274
    To navigate to a new record just use this line:

    DoCmd.GoToRecord , , acNewRec

    The data should automatically save for you and the old data should clear.

    NB: This is only true if you are using a recordset based on a table with bound controls.

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

Similar Threads

  1. Replies: 3
    Last Post: 10-21-2013, 10:51 AM
  2. Replies: 1
    Last Post: 03-05-2013, 04:47 PM
  3. Problems With Adding Data Back To Table
    By jimbob90 in forum Access
    Replies: 10
    Last Post: 09-30-2012, 05:28 PM
  4. Problems with data entry form Access 2010
    By OfficeQuestions in forum Access
    Replies: 4
    Last Post: 09-23-2010, 01:42 PM
  5. Problems adding a drop down box to report/query
    By rachelm920 in forum Access
    Replies: 1
    Last Post: 05-14-2009, 09:19 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