Results 1 to 4 of 4
  1. #1
    Moondoggy's Avatar
    Moondoggy is offline Novice
    Windows 10 Access 2010 64bit
    Join Date
    Apr 2019
    Location
    Pace, FL
    Posts
    2

    Newbie needs help with creating buttons on Access Form

    Although I wrote a lot of VB Script utilities in my time I never did much with Access. I'm trying to take the Contacts database that you can get from Microsoft and modify it as a church membership DB so we can print labels and also print a directory of members. So far I've been pretty successful in modifying the tables the forms and creating the church directory report but there's a few nagging problems that I'm having trouble with and I cannot yet figure out what I need to do.

    The Contacts Database automatically opens displaying the Contacts List form, which is fine. On that form is a New Contacts button that opens the Contact Details form with all fields being blank which is also fine. However, if you launch the Contact Details form from the Object Forms on the left side of the screen the form will automatically the first record in the database. Furthermore, the Contact Details form also has a search field that you can display any of the records in the database.

    What I want to do is to add 2 buttons to the Contact Details Form. What I want the first button to do is clear all fields on the form to facilitate the addition of a new record. In other words, if the form is launched and is displaying a record or the user initiated a search and the form is displaying the found record from the database I want the user to be able to press a button to clear the form so that a new record can be added. The second button is just a button to close the form which should leave the database open displaying the Contacts List form that has been there all along in the background.

    As I mentioned I'm a newbie to Access and I have been unable to determine how to setup the function behind the button. I was hoping that this would be as simple as selecting a function that would automatically be available within Access but so far I have not seen anything during the button setup that will do what I want to do.



    Can anyone give me the "Access for Dummies" version on how to add both of these buttons? Thanks.

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,527
    (best)
    if the form is connected to the table, you dont clear the fields, you just say Add new record:
    DoCmd.GoToRecord , , acNewRec

    (not best)
    if the form is not bound to a table,then program it for each field ,
    txtBox1 = null
    txtBox2 = null

  3. #3
    Moondoggy's Avatar
    Moondoggy is offline Novice
    Windows 10 Access 2010 64bit
    Join Date
    Apr 2019
    Location
    Pace, FL
    Posts
    2
    Quote Originally Posted by ranman256 View Post
    (best)
    if the form is connected to the table, you dont clear the fields, you just say Add new record:
    DoCmd.GoToRecord , , acNewRec

    (not best)
    if the form is not bound to a table,then program it for each field ,
    txtBox1 = null
    txtBox2 = null
    Thanks for the instructions. So simple once you get the right info. The "best" method did the trick with a bit of help from the Wizard.

    That being said, do you have any similar method for the second button that will close the Contact Detail form but not close the database?

  4. #4
    hammerman is offline Advanced Beginner
    Windows 7 32bit Access 2013
    Join Date
    Jul 2014
    Posts
    32
    Quote Originally Posted by Moondoggy View Post
    Thanks for the instructions. So simple once you get the right info. The "best" method did the trick with a bit of help from the Wizard.

    That being said, do you have any similar method for the second button that will close the Contact Detail form but not close the database?
    Code behind button could be as simple as" me.close". That would work if the (other) form or the table was still open, (and not closed by opening the form. If your frm_add_New form was not opened by ...frmBrowseTo... command). Enter the me.close command on the 'on_Click' event subroutine in the 'Event' tab of the property sheet. {You may need other options, parameters and code, if you want the user to be able to cancel out of that option}. but the simple action is do-able.


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

Similar Threads

  1. Replies: 1
    Last Post: 01-14-2016, 10:19 PM
  2. Replies: 8
    Last Post: 11-10-2015, 08:50 AM
  3. Tips creating a table (newbie help!)
    By hellfire45 in forum Access
    Replies: 2
    Last Post: 06-24-2015, 09:57 AM
  4. Creating Buttons on a form keeps returning a visual basic error
    By Robin Banks in forum Database Design
    Replies: 1
    Last Post: 02-28-2012, 07:48 AM
  5. Access 2003 - Creating Buttons from a Table
    By Speedy in forum Programming
    Replies: 2
    Last Post: 02-28-2009, 05:32 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