Results 1 to 7 of 7
  1. #1
    RobFlott is offline Novice
    Windows XP Access 2010 32bit
    Join Date
    May 2015
    Posts
    22

    How to clear data entries in a Form

    I have a Form containing several Combo Boxes.
    The user opens this form and makes entries based on each of the Combo Boxes.
    After they enter all the data they click a button that posts the data into the data table.

    The problem occurs when the user returns to that form, and the previous data entries remain,
    and I want to clear the entries in each Combo Box.

    I tried writing the code below to the OnOpen event for the Form:

    Private Sub Form_Open(Cancel As Integer)


    Combo94.Value = ""
    End Sub

    But I get a run-time error (#2448) stating "I can't assign a value to this object"

    Can anyone help me on how to 'clear' these pervious selections in each Combo Box?

    Thank you,

    Rob

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,550
    just set them all to ""
    Combo94 = ""

    DONT use the .VALUE property.

  3. #3
    RobFlott is offline Novice
    Windows XP Access 2010 32bit
    Join Date
    May 2015
    Posts
    22
    Thanks Ranman, I tried your suggestion but still get an error message stating I cannot assign a value to this object.

    Private Sub Form_Open(Cancel As Integer)
    Combo94 = ""
    cboMgr = ""
    cboBanner = ""
    End Sub

    I also tried the following but got the same results:

    Private Sub Form_Open(Cancel As Integer)
    With Form_frmKPI
    Combo94 = ""
    cboMgr = ""
    cboBanner = ""
    End with
    End Sub

    Is there some other code I need to use that would clear the data appearing in each ComboBox?

  4. #4
    ssanfu is offline Master of Nothing
    Windows XP Access 2010 32bit
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    The problem occurs when the user returns to that form, and the previous data entries remain,
    The "previous data entries" remain because the are in the table.
    Forms
    do not "have" data. Forms are a way to view the data stored in a table.


    If you have a bound form (sounds like you do), you can set the form to "Data Entry" mode. This allows you to add new records, but cannot view existing records (in that form).

    Option two is to move to a new record. either on form open or on a button click.
    Code:
    DoCmd.GoToRecord , , acNewRec

  5. #5
    RobFlott is offline Novice
    Windows XP Access 2010 32bit
    Join Date
    May 2015
    Posts
    22
    Steve, thanks for the quick reply...I'll try these and let you know what happens

    Rob

  6. #6
    Missinglinq's Avatar
    Missinglinq is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Location
    Richmond (Virginia, not North Yorkshire!)
    Posts
    3,018
    While Steve's advice is probably the way to go (it's how I would do this) the probable cause of the error you got is that the Form_Open event is too early to assign a value to a Control. I suspect that placing this code in the Form_Load event would have worked.

    Linq ;0)>

  7. #7
    RobFlott is offline Novice
    Windows XP Access 2010 32bit
    Join Date
    May 2015
    Posts
    22
    Steve, thank you very much...per your suggestion in the 'OpenForm' macro I changed the 'Data Mode' from Edit to Add.

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

Similar Threads

  1. Creating a Form Button to Clear Table Data
    By wojosh6 in forum Access
    Replies: 5
    Last Post: 12-10-2015, 01:45 PM
  2. Multiple data entries on a form
    By argsemapp in forum Forms
    Replies: 1
    Last Post: 12-03-2013, 03:04 PM
  3. Replies: 2
    Last Post: 04-24-2013, 11:52 AM
  4. clear past data during form open
    By newaccess in forum Forms
    Replies: 1
    Last Post: 01-09-2013, 10:55 AM
  5. Replies: 4
    Last Post: 01-04-2013, 04:03 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