Results 1 to 12 of 12
  1. #1
    Join Date
    May 2006
    Posts
    178

    Unanswered: do not create the record until i press the button?

    Hey guys its me again,

    I have a form, The unique PK is Autonumbered, As soon as i put data into one of the text boxes on the form, the record is created. I want it so that The record cannot be created up until i press the "SAVE" command button.

    How would i achieve this?

    Many thanks

    ~Aboo

  2. #2
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    the only way I can see of doing this is to use unbound recordsets/forms. Although its not for the fainthearted, it is the way to go to devlop Access applications that are scalable, usually this goes hand in hand with server databases.

    it means leaving behind the 'nice' features of Access, is simple drag and drop form design.

    however it sounds to me as if you are trying to use the autonumber field for something it isn't designed for. autonumber is a way of generating a column which makes that rows unique... it has no meaning outside the system, esepcially not as an invocie number, GRN, receipt No. if what you want is a contiguous number then you should go down a different route. find the last used number and add to it.
    I'd rather be riding on the Tiger 800 or the Norton

  3. #3
    Join Date
    May 2006
    Posts
    178
    Hey Healdem,

    What im trying to stop is records being created on a table that have no meaningful information in them.

    I want the user to make sure he/she fills in all the fields otherwise the record wont be saved.

    Im sorry if i didnt communicate this problem clearly, sometimes my fingers type faster than i can think..lol

    Do you understand what im saying?

  4. #4
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    so if ypou are concened about not savi ng duff records then consider displaying a mesage called from the forms "before update" event saying t the effect

    are you certain you "wish to save the record". mind you your users will soon get might pissed off having to answer yes to such prompts. you may need to play about to find which event is most important.
    if you don't care about sequentioal numbers then you could happily use the after insert event
    I'd rather be riding on the Tiger 800 or the Norton

  5. #5
    Join Date
    Nov 2007
    Location
    Adelaide, South Australia
    Posts
    4,049
    Validate all the fields in your Before Update event for the form?
    Owner and Manager of
    CypherBYTE, Microsoft Access Development Specialists.
    Microsoft Access MCP.
    And all around nice guy!


    "Heck it's something understood by accountants ... so it can't be 'that' difficult..." -- Healdem
    "...teach a man to code and he'll be frustrated for life! " -- georgev

  6. #6
    Join Date
    May 2006
    Posts
    178
    What do you mean StarTrekker?

    I want to make sure that everything is populated and the user is happy with the information he/she has entered before hitting the save button.


    Any ideas?


    Regards


    Aboo

  7. #7
    Join Date
    Nov 2007
    Location
    Adelaide, South Australia
    Posts
    4,049
    I want to make sure that everything is populated
    So in your save button code, validate that the fields are populated with code such as:

    Code:
    If Me.ControlName = "" or IsNull(Me.ControlName) Then
       bCancel = True
    End If
    
    ... more tests...
    
    If bCancel = False Then
       Do your save commands...
    End If
    That kind of thing.

    ... and the user is happy with the information he/she has entered before hitting the save button.
    Well if you have a save button, then this is a user intellect issue. The user should only hit save when they are happy.
    Owner and Manager of
    CypherBYTE, Microsoft Access Development Specialists.
    Microsoft Access MCP.
    And all around nice guy!


    "Heck it's something understood by accountants ... so it can't be 'that' difficult..." -- Healdem
    "...teach a man to code and he'll be frustrated for life! " -- georgev

  8. #8
    Join Date
    May 2006
    Posts
    178
    Trekker,

    As soon as a user inputs somthing in a field and decides not to proceed with creating the record. Access automatically creates a ID for that record and stores it in a table.Thats what i dont want it to do, creating blank records.

    Aboo

  9. #9
    Join Date
    Jun 2007
    Location
    Maitland NSW,Australia
    Posts
    388
    My preference would be as discussed earlier to use an unbound form where you can do your validation and display a button to Save the entry.

    Alternatively, you could use a temporary table to store the data input, then do your validation and if there are no errors in the validation, append from the temporary table to your main table. You must also delete from your temporary table after you append to your main table.

  10. #10
    Join Date
    Nov 2007
    Location
    Adelaide, South Australia
    Posts
    4,049
    aboo,

    does your form have a save button or not?

    Is the form unbound or bound?

    Either one of my answers in this topic is correct, but I can't tell which one.

    If you have an unbound form, then Access won't store anything until a save button is pressed, so you do your data validation in your save button.

    If you have a bound form, no save button is needed and you do the validation in the BeforeUpdate event for your form.
    Owner and Manager of
    CypherBYTE, Microsoft Access Development Specialists.
    Microsoft Access MCP.
    And all around nice guy!


    "Heck it's something understood by accountants ... so it can't be 'that' difficult..." -- Healdem
    "...teach a man to code and he'll be frustrated for life! " -- georgev

  11. #11
    Join Date
    May 2006
    Posts
    178
    Hi guys,

    thanks again for your responses , views and ideas.

    Yes the form is bound to the table. Currently ther eis no button on the form. I want to create one.

    So i take it the best thing to do is, unbind it. save it to a temp table then save it across?

    Aboo

  12. #12
    Join Date
    Nov 2007
    Location
    Adelaide, South Australia
    Posts
    4,049
    Best thing to do would be:

    If you have an unbound form, then Access won't store anything until a save button is pressed, so you do your data validation in your save button.
    Using a temporary table to store it first is not an optimal solution.
    Owner and Manager of
    CypherBYTE, Microsoft Access Development Specialists.
    Microsoft Access MCP.
    And all around nice guy!


    "Heck it's something understood by accountants ... so it can't be 'that' difficult..." -- Healdem
    "...teach a man to code and he'll be frustrated for life! " -- georgev

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •