Results 1 to 10 of 10
  1. #1
    Skroof is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Apr 2012
    Location
    South Africa
    Posts
    21

    Button add record


    Hi, How do i make a button add a record and launch another form thereafter. e.g You enter your details, hit on "Add Record" then it saves the record and automatically opens another form to enter another different data. What VBA code can i attach to such a button.

  2. #2
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows XP Access 2003
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,610
    You can force a save with:
    Code:
    If Me.Dirty = True Then
      Me.Dirty = False
    End If
    You can then open a form using the OpenForm method of DoCmd. The help files will give you the syntax and detail or try this link:http://msdn.microsoft.com/en-us/libr...ffice.10).aspx
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  3. #3
    Skroof is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Apr 2012
    Location
    South Africa
    Posts
    21
    Hi Bob Fitzpatrick
    Where do i add this code ?

  4. #4
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows XP Access 2003
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,610
    Create a button with the wizard to open the second form. Put the code I gave you in the button's On Click event, below Dim declarations that the wizard has written.
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  5. #5
    Skroof is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Apr 2012
    Location
    South Africa
    Posts
    21
    This is what the button has:

    Option Compare Database
    Private Sub btnSavenReturn_Click()
    End Sub

  6. #6
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows XP Access 2003
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,610
    Try this:
    Private Sub btnSavenReturn_Click()
    If Me.Dirty = True Then
    Me.Dirty = False
    End If
    Docmd.OpenForm "[NameOfFormToBeOpened]"
    End Sub
    Change [NameOfFormToBeOpened] with your form name.
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  7. #7
    Skroof is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Apr 2012
    Location
    South Africa
    Posts
    21
    Wow...Bob Fitzpatrick
    This worked like a charm, thanks man. ow do i make it clear that data after saving it. It saves data, open the new form(AppointmentInformation), and it is all cool but it does not clear data in the text box.

  8. #8
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows XP Access 2003
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,610
    Try This:
    Code:
    Private Sub btnSavenReturn_Click()
    If Me.Dirty = True Then
    Me.Dirty = False
    End If
    DoCmd.GoToRecord , , acNewRec
    Docmd.OpenForm "[AppointmentInformation]"
    End Sub
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  9. #9
    Skroof is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Apr 2012
    Location
    South Africa
    Posts
    21
    Bob Fitzpatrick, you are a star man - now sorted. You made my day. Keep up the good work man.

  10. #10
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows XP Access 2003
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,610
    Quote Originally Posted by Skroof View Post
    Bob Fitzpatrick, you are a star man - now sorted. You made my day. Keep up the good work man.
    Thank you. Glad to help.
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

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

Similar Threads

  1. Replies: 4
    Last Post: 07-22-2011, 12:52 PM
  2. Record Next Button
    By Chipper in forum Forms
    Replies: 0
    Last Post: 06-20-2011, 03:23 PM
  3. Replies: 10
    Last Post: 03-21-2011, 02:46 PM
  4. Add new record button
    By smikkelsen in forum Access
    Replies: 0
    Last Post: 03-29-2010, 02:55 PM
  5. Replies: 6
    Last Post: 02-09-2010, 07:53 AM

Tags for this Thread

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