A Small Problem

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Sidraa
    New Member
    • Aug 2007
    • 5

    A Small Problem

    hello i hav come across this small problem...i made a small project using Access...now what happens is when i enter the data through a form it gets calculated by a query and then gets stored in a table...when i wish to re-enter some values the form opens wid the previous values and when i replace the previous values with the new ones i get an error which says "Write Conflict" and stuff...now tell me wat should i do about it....and i want to set 0 as the default value for the forms....how do i do it....
  • Jim Doherty
    Recognized Expert Contributor
    • Aug 2007
    • 897

    #2
    Originally posted by Sidraa
    hello i hav come across this small problem...i made a small project using Access...now what happens is when i enter the data through a form it gets calculated by a query and then gets stored in a table...when i wish to re-enter some values the form opens wid the previous values and when i replace the previous values with the new ones i get an error which says "Write Conflict" and stuff...now tell me wat should i do about it....and i want to set 0 as the default value for the forms....how do i do it....
    If you are using an Access Project ADP file then look at the RESYNCH property of the form to ensure you are refreshing the form with the latest data following a save operation. Loads of references to this online and in Access help

    Regards

    Jim

    Comment

    • Sidraa
      New Member
      • Aug 2007
      • 5

      #3
      Originally posted by Jim Doherty
      If you are using an Access Project ADP file then look at the RESYNCH property of the form to ensure you are refreshing the form with the latest data following a save operation. Loads of references to this online and in Access help

      Regards

      Jim
      Sir,
      i am not using an ADP file....as i used Access for the first time i did it with normal db format. Please consider my problem once again.

      Comment

      • Jim Doherty
        Recognized Expert Contributor
        • Aug 2007
        • 897

        #4
        Originally posted by Sidraa
        Sir,
        i am not using an ADP file....as i used Access for the first time i did it with normal db format. Please consider my problem once again.
        What is the forms recordsource is it a table or a saved query or is it an SQL statement?

        You mention entering a value and a query calculating a value and storing that in your table. (I assume this to be an UPDATE query? is it serviced by a button? or does it kick in as part of any event procedure like the ON_CURRENT ) Is it the same table or a different table servicing the form or is it a different table?

        A write conflict will be occurring where Access considers it cannot save a data value due to some other event sharing that value at precisely the moment when another event is editing the same value. This could be as simple as you opening the form for editing and a separate query (maybe the one you speak about also trying to save the data both at exactly the same time.

        Unfortunately without knowing the structure of your database currently this lock could be anywhere. Is your database very simple or complex.

        To assist you I think we need to know a little bit more about the layout fields etc form useage etc. What does making a default of zero mean? this could be anything! with respect

        Not very helpful I guess and for that may I apologise but I am feeling a little blind here

        Jim

        Comment

        • Sidraa
          New Member
          • Aug 2007
          • 5

          #5
          the form's record source is a table. form has a button having VB code behind it which runs an update query, then the values in the table are updated. i have only one table in this.what i want this thing to do is: i have 2 forms one to add the values in the table and the other for subtracting the values from the same table.its like i have a particular stock of something, if more comes in i add it to the current stock and when some of it goes i subtract it from the current stock. its a simple database.now what happens is when i enter the data from the add stock form it works fine but when i use the remove stock form for subtracting some values from the table it either overwrites the current values or gives this write conflict.now i thought that if i could set the default value for all the fields as 0 then this overwriting of values can be stopped.what should i do for this write conflict????

          Comment

          • Jim Doherty
            Recognized Expert Contributor
            • Aug 2007
            • 897

            #6
            Originally posted by Sidraa
            the form's record source is a table. form has a button having VB code behind it which runs an update query, then the values in the table are updated. i have only one table in this.what i want this thing to do is: i have 2 forms one to add the values in the table and the other for subtracting the values from the same table.its like i have a particular stock of something, if more comes in i add it to the current stock and when some of it goes i subtract it from the current stock. its a simple database.now what happens is when i enter the data from the add stock form it works fine but when i use the remove stock form for subtracting some values from the table it either overwrites the current values or gives this write conflict.now i thought that if i could set the default value for all the fields as 0 then this overwriting of values can be stopped.what should i do for this write conflict????
            Ok it occurs to me that you have an 'entire recordset' open for editing namely the 'entire' table by using the form for adding records. In this scenario Access will LOCK the entire 'Page' of data on the assumption that you intend editing those records you have retrieved as part of the forms recordset.

            You say you have TWO separate forms my guess is you are opening a second form for removing items from your stock BUT this form is also based on the same table? but........you are opening both of those forms at the same time which means the table is being opened 'twice' if this is the case then this is where your write conflict exists.

            You can see what I mean by demonstrating it for yourself if you quickly create two separate forms using the autoform feature of access and save them as Form! and Form2 or something, then open both of them up and switch between both of them and edit the same record 'with them both open' you will have a pop up screen write conflict dialog box

            If my presumptions are true then my advice is drop the second form and work wholly within your first form by 'filtering for' those records that you wish to remove you could do this by 'applying a filter' to your records to suit your requirements and removing any filtration when you have done.If your form is set up as I think it is then (ie: not DATA entry only) then try clicking on any text field on screen then RIGHT mouse click and in the shortcut menu you see 'Filter by Selection' and also 'Filter for' and also 'Remove filter/Sort'

            In addition to this I would base an recordsource for any form you create on a QUERY rather than the table directly. This can be as simple as dumping all the fields into the query grid for your table saving the query with a suitable name qryProducts or something like that and setting a sort order in the query to your liking (you may wish of course not to bother with a sort and simply leave the sort based on your primary key row identifier)

            Hope this helps you

            Jim

            Comment

            • Sidraa
              New Member
              • Aug 2007
              • 5

              #7
              Oooo Thankyou Soo Much.....i Have Done It.....may God Bless U

              Comment

              • Jim Doherty
                Recognized Expert Contributor
                • Aug 2007
                • 897

                #8
                Originally posted by Sidraa
                Oooo Thankyou Soo Much.....i Have Done It.....may God Bless U
                You are welcome I am glad you it sorted it for you

                Jim

                Comment

                • Sidraa
                  New Member
                  • Aug 2007
                  • 5

                  #9
                  Originally posted by Jim Doherty
                  You are welcome I am glad you it sorted it for you

                  Jim

                  hey its almost over now there is one small problem left....when i enter some values through a form it works fine...but when i open the form again i see the previous values...i want the previous values to get cleaned up when i open the form again or when i enter the values and they get calculated they shouldn't remain in the form after that.i want a clean form every time i open it...how do i do it.....

                  Comment

                  • Jim Doherty
                    Recognized Expert Contributor
                    • Aug 2007
                    • 897

                    #10
                    Originally posted by Sidraa
                    hey its almost over now there is one small problem left....when i enter some values through a form it works fine...but when i open the form again i see the previous values...i want the previous values to get cleaned up when i open the form again or when i enter the values and they get calculated they shouldn't remain in the form after that.i want a clean form every time i open it...how do i do it.....
                    OK Sidraa,

                    Well I am assuming by now that you only have the one form and that you dumped the second form like I mentioned.

                    To answer your question hopefully to the point where it helps you I have to ramble on here a little so forgive me...

                    With Access forms the form itself merely acts as a visual 'frontend' if you like, an interface between the table or query that it services. This, as you may well have guessed all stems from the form actually knowing where it gets its data from... so to speak.

                    This is set by the 'Recordsource' property of the form which unless you stipulate otherwise will do exactly as you tell it to....so...if you were to set its recordsource as only a 'table' then it will by default open a table and ALL of its records each time you open the form.

                    If you set its record source to a saved query shall we 'qryProducts' where the query might restrict for instance by a 'product status' field containing the word 'sold' the form would only show those records where the products had been sold and so on.

                    In the case of either dataset, when the records are all displayed to you on screen you can go further by 'Filtering' those records to restrict the recordset further and you can keep filtering the same dataset in each field until you get to a point where no records display at all because you have filtered so much if you get me.

                    The actual filtration command process ' the syntax' if you will in an Access form is stored in its FILTER property setting each time you make a filtration.

                    One of the quirks of Access, which some say is an annoying feature, is that Access sometimes saves this filtration command with the form when it closes the form down, this is particularly so if you had a filtration command evident in this property setting at anytime whilst in DESIGN mode so that when you close the form and save the design changes, it will automatically also save any filtration command as a feature of the form.

                    Certain assumptions are made by Microsoft programmers, which they have to do of course, when they presume what you as a user customer wishes to do. In practice what this means is that whenever you open the form again you always get the previous filtration dataset displayed to you.

                    Some people love it, some don't.....perso nally I don't because after five minutes or so I can't always remember what it was I opened the form for previously etc etc. prompting me to think hmmm "how do I get my records all back" or "How do I get back the records this form is 'supposed' to deal with"

                    You do this by 'Removing all and any filters' in effect 'Show all Records'

                    You should see the command 'SHOW ALL RECORDS' on the menubar in the RECORDS menu. When you issue that command and it removes current filters and does as it says on the tin so to speak.

                    Go into your form in design and select the form itself in design mode (click on the little box at the interestion of the rulers) then menubar VIEW ...PROPERTIES and look in the properties dialog box (the caption of the dialog should read 'Form' that pops up you will see the following properties visible....thes e are the properties of the FORM itself (note not a textbox not a command button.......th e FORM) Make sure the caption of that dialog box says form otherwise you are looking at the properties of some other screen control you have inadvertently selected on screen. Note the following properties

                    Recordsource
                    Filter
                    Order By
                    Allow Filters
                    Caption
                    DefaultView
                    Views Allowed
                    Allow Edits
                    Allow Deletions
                    Allow Additions
                    Data Entry

                    At this point I suspect, if you do not know already that you can control almost every sequence of events inherent within the form.

                    In your case look see if there is anything in the FILTER setting if so remove it close and save the form when asked.

                    The DATA ENTRY property for instance if set to yes will make the form open each and every time to a NEW row ready to accept a new record (essentially it always opens to one blank row only and doesn't drag up the dataset)

                    Check these settings, play with them, familarise yourself with what they do and if you don't know hit the F1 key when the cursor is in the corresponding textbox and access will tell you what it is supposed to be for.

                    Forgive me but I am not sure what you mean by 'CLEANED UP' and THEY GET CALCULATED' in my computer programming parlance they mean a whole load of possibilities and I cannot precisely interpet what you mean by it

                    I think bottom line that you should look at the FILTER activity first and foremost, ensure, Access isnt saving any filter on close and if it is doing then I can then tell you how to actually STOP it doing so but we are not there yet.

                    Oh go on then.... here is how we do it on closing the form using a standard CLOSE button that we might have created with the wizard the actual VBA code
                    generated for that is simply this

                    DoCmd. Close

                    If you are able to locate this command in the vba editor by playing with your db then if you alter the command to this

                    DoCmd.Close acform, Me, acsaveNo

                    then access will the close the form and NOT save any design changes at runtime.

                    If you get stuck then PM me and I will come back to you. I am not always online and not always as sharp as I would like to be on keeping account of my posting responses

                    Kind Regards

                    Jim

                    Comment

                    Working...