Results 1 to 10 of 10
  1. #1
    stryder09 is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Feb 2011
    Posts
    85

    Clear fields in a record

    Ok, So I have a form that I use as a set up form for weight challenges. On this form you enter a date the period of time you wish the challenge to go on for ex. 6 weeks. A Name for the challenge, select the people involved with the challenge and finallly the % of weight loss you want. Once this information is filled out you exit the form. I have it set up so that only the one form exists and another cannot be created.



    I then have another form that draws all the information into it and I then Track weigh ins, body fat %, weight loss from the data from the setUp Form above.. I want to be able push a button and clear the data in the SetUp Form. I know how to delete the record but if I do that and I go back into the setup it tells me that I cannot create a new record because I have it set to only 1 record.

    So how do I create a query that will clear the fields but not delete the record?

    I tried using

    DELETE [ChallengeName] AND [ChallengeStartingDate] FROM tblChallenge1SetUp

    But this deleted the entire record.

    As always any help would be appreciated

    Brad

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,522
    You'd want an update query:

    UPDATE TableName SET FieldName = Null, AnotherField = ""

    Depending on your specifics, either Null or "" might be correct.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    stryder09 is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Feb 2011
    Posts
    85
    thank you I will try that today.

  4. #4
    stryder09 is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Feb 2011
    Posts
    85
    Okay Final question. I now have a table which has 10 records in it. I want to just change record 1 using the Update from above. How do I specify that I only want to change the fields in record #1?

  5. #5
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,522
    Add a criteria, like

    WHERE FieldName = 1
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  6. #6
    stryder09 is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Feb 2011
    Posts
    85
    I have multiple fields to change. I put in

    UPDATE tblBMI WHERE [ProfileNumber] = 1 Set [NameOfPerson] ="Profile1", [password] = "profile1";

    It isn't working, should I try and write it a different way? I have more than just these two fields to update, more like 10 fields to update.

  7. #7
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,522
    The proper syntax:

    UPDATE...
    SET...
    WHERE...
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  8. #8
    stryder09 is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Feb 2011
    Posts
    85
    So it should be like the following?

    UPDATE tblBMI Set [NameOfPerson] ="Profile1", [password] = "profile1" WHERE [ProfileNumber] = 1;

  9. #9
    stryder09 is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Feb 2011
    Posts
    85
    okay rewrote it as

    UPDATE tblBMI Set [NameOfPerson] ="Profile1", [password] = "profile1" WHERE [ProfileNumber] = 1;

    And it works perfectly, thank you.

  10. #10
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,522
    No problemo!
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

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

Similar Threads

  1. 2 fields the same in a record
    By joeldamole in forum Queries
    Replies: 1
    Last Post: 03-08-2011, 07:04 AM
  2. Replies: 0
    Last Post: 02-25-2011, 09:40 AM
  3. How to clear the form?
    By Mrcams in forum Access
    Replies: 3
    Last Post: 01-03-2011, 12:15 AM
  4. Clear all checkboxes?
    By thekruser in forum Forms
    Replies: 2
    Last Post: 09-16-2010, 09:50 AM
  5. Clear a Field OnClick
    By eww in forum Forms
    Replies: 3
    Last Post: 08-19-2010, 01:55 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