Results 1 to 5 of 5
  1. #1
    Musicguy2112 is offline Novice
    Windows XP Access 2007
    Join Date
    Oct 2011
    Posts
    8

    adding a value in a field when a button is pressed

    I would like to add a value to a field on a form based on a button on that same form. Anyone know how to do this?
    Any help appreciated!
    Thanks in advance!


  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,822
    Is this a textbox bound to field of form's RecordSource? Is this field empty at the time of click?

    Maybe simply in the button's Click event:

    If IsNull(Me!fieldname) Then Me!fieldname = some value

    Why do you need to do this?
    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.

  3. #3
    Musicguy2112 is offline Novice
    Windows XP Access 2007
    Join Date
    Oct 2011
    Posts
    8
    Thanks! I'm a newbie on access. Actually found a way to do it. On the click event of the button, I just added "fieldName.Value=ValueName" which worked fine.

    I need to do this to be able to show on another form only records based on this value. Is there a better way of doing this? Thanks for your help.

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,822
    Depends.

    Is the textbox actually bound to a field of form's RecordSource. If yes, then you are actually changing the value in the table. Is this your intent?
    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
    hertfordkc is offline 18 year novice
    Windows XP Access 2007
    Join Date
    Mar 2011
    Posts
    481
    The example MyTestForm.zip at this thread might be useful.
    https://www.accessforums.net/forms/fo...xes-18492.html
    In the simplest case, using VBA to work the forms is overkill. However, open Frm1 and try clicking on the listboxes, and look the VBA for both Frm1 and Frm2.

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

Similar Threads

  1. adding a sort control button
    By darklite in forum Forms
    Replies: 5
    Last Post: 01-24-2011, 03:32 PM
  2. Adding Pop-ups via Command Button
    By jlclark4 in forum Forms
    Replies: 1
    Last Post: 01-05-2011, 02:41 PM
  3. Lock Record when "Add" button is pressed
    By jo15765 in forum Access
    Replies: 34
    Last Post: 11-28-2010, 08:50 PM
  4. Replies: 3
    Last Post: 10-28-2010, 07:02 AM
  5. Adding Command Button To Form
    By uneek78 in forum Forms
    Replies: 7
    Last Post: 03-27-2009, 07:43 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