Solved Correct way to update data (1 Viewer)

lacampeona

Registered User.
Local time
Today, 07:08
Joined
Dec 28, 2015
Messages
392
Hello
yes I know I was thinking wrong. Becouse of that I ask for experts opinion. I know that the status must be from the transacion table.
But becouse I have a form with all the data from the begining and I also have status there and there is where the user then check all the data.
hmmm maybe I will cut of the status from the first form? and I will show only the data from the transacion table?
You mean using update statment to uptade data in primary table or another is not good idea to use?
thank you
 

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Today, 00:08
Joined
Feb 28, 2001
Messages
27,148
You are still thinking narrowly. With a QUERY as your form's or report's data source, you can have the best of both worlds. Contemplate my long discussion in post #9 and the second query in post #13 that joins A and Query1. Do you not see that this gives you item data and most recent status in one place?

Let me ask another question: It has not seemed to be a problem so far from our end, but are you having trouble because to you, English is a second language? I am sensing that you are translating as you go - and I think you are doing a good job of it. But... is there another way for us to clarify what we are trying to say? I would hate to leave you confused because my words don't mean the same thing to you that they do to me.
 

lacampeona

Registered User.
Local time
Today, 07:08
Joined
Dec 28, 2015
Messages
392
Hi
Yes English is my second language...i speak 7 languages...
I understand what all of you are saying.. it is me I just do not know how to make that with one or 2 querys?
I have one primary table and then 3 transacion tables ( 3 diferent systems which can use the item, but one item only one system) ... and I dont get what I want with one/2 querys....
i just do not know how to make query with multiple tables?
I have to say that I have status field in all 4 tables ( one primary table and 3 transcacion tables)
I make a query and I have duplicate ID and then 3 diferents statuses....
is just me and sorry for my english and if i complicate all that
can someone show me how to create query with multiple tables? some example so i can study what i am doing wrong? my PK and FK? ohh
:unsure:
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 01:08
Joined
Feb 19, 2002
Messages
43,233
Seven languages is pretty impressive. VBA should be a snap since it is a small subset of English:) Most Americans can't even speak one:) Our schools have practically abandoned the teaching of grammar.

Why do you have multiple transaction tables? Couldn't you use a code so you know what the transaction is for? Do you think that Inventory applications have separate tables for separate transaction types? The answer is NO.
 

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Today, 00:08
Joined
Feb 28, 2001
Messages
27,148
My 2nd query example from post #13 shows a two-source JOIN. The general form of a two-table query for MOST (not all) applications is:

Code:
SELECT A.Afield1, A.Afield2, ..., B.Bfield1, B.BField2, ... FROM A INNER JOIN B ON A.Afield1 = B.Bfield1 WHERE .... ORDER BY ... <<<other options>>>;

You have fields in A and B that are related by some common field, which is Afield1 and Bfield1 in this example You take fields you want from A and fields from B, qualifying their locations with the A or B prefixes as shown. I used an INNER JOIN but there are other options. INNER JOIN is the easiest for starters. The JOIN occurs on two fields, one from A and one from B, that must match in order to say they are related. Note that depending on the exact nature of the relationship, it would be possible to have multiple matches in one table matched to a single field in the other table. If so, you will get as many records in the query as whichever one has the multiple matches. You will get every combination.

So for your original question, you have one item record with a unique item ID and you had the possibilities of multiple action records starting from NEW but including IN USE or RETURNED or IN REPAIR or whatever is appropriate to the item. You get this because the rules of Access are all about combinations. When you have a single-table there are no combinations. When you have a multi-table query, Access will give you combinations and permutations like crazy - unless you limit them with ON clauses and WHERE clauses.

I asked about your English to verify that we were not giving YOU a language problem. If you believe your problem simply comes from a lack of full understanding of Access, then we know that the miscommunication isn't due to our being careless. I think you are doing fine with language. But if you are not comfortable with queries, that is a different problem.

I would advise you to study queries because in Access, they are the workhorses. Tables do their part, of course, but they just store data. They can, of course, be targets of INSERT INTO, UPDATE, or DELETE actions, but otherwise they just lie there, sitting around doing nothing. Queries can actually DO things to data. They are (as we say in the USA) "worth their weight in gold."

The thing to know about queries is that you can drive many things from them. A query can reference another query (e.g. my 2nd query in post #13 references an earlier query.) They can be record sources for forms or reports, although with reports sometimes Access gets a little stubborn. VBA Recordsets can work with queries quite easily. Queries are everywhere in Access. Therefore, do some reading so you can make queries become your friend.
 

lacampeona

Registered User.
Local time
Today, 07:08
Joined
Dec 28, 2015
Messages
392
I have one primary table = table A , here is the basic info of the item and here starts everything
then this item from table A can be used on 3 different systems ( imagine: ford, toyota, ferrari) this mean 3 different tables? ( table B ford , table C toyota, table D ferrrari)
when user start entering data in table A he choose which system this item will use, once the item has the system then this item can be used only on one system, if you choose for item 1 ford then this item 1 is used only on ford and all the data for the usage will go to the table B ford,if you choose for item 4 toyota then this item 4 is used only on toyota and all the data for the usage will go to the table C toyota, if you choose for item 5 ferrari then this item 5 is used only on ferrari and all the data for the usage will go to the table D ferrari,
I need to have separate evidence of every sytem ( imagine: ford, toyota, ferrari), becouse every system have some different fields and also becouse some system must be released , if the system is not relased you can not use the item for usage, in ford you have to calculate how many times the item was used, in toyota you have to write which oil is used and so on..

and becouse of that every table has status, becouse ford can be relased and toyota not, if ford is not relased you can not use it....

maybe i create that wrong? hmmm :oops:

and yes i will study querys..i know how to make simple query but multiple tables is strange i dont get data that i want...
 

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Today, 00:08
Joined
Feb 28, 2001
Messages
27,148
then this item from table A can be used on 3 different systems ( imagine: ford, toyota, ferrari) this mean 3 different tables? ( table B ford , table C toyota, table D ferrrari)
No, it does not mean 3 different tables. It means one table that includes a field that SAYS Ford, Toyota, Ferrari. And you use queries if you want to see ONLY Fords or ONLY Toyotas or ONLY Ferraris.

The usage table DOESN'T CARE what it is because the item definition table DOES care. All that matters is that your status would be kept in the usage table NO MATTER WHAT the system happens to be. Is there that much difference between these systems for the USAGE table?

Now, as to different fields for different systems... Really? Are we talking about a LOT of fields or just a couple? Because there is nothing wrong with the idea that a given field will be blank for some things and not blank for others. Splitting out these different fields IS done sometimes, but not unless there is a very large number of totally unique fields that differ from system to system.

I'm beginning to think that at least part of your problem is NORMALIZATION. Have you studied that? It is crucial to having a good design. If you need to study that, here is my advice. You CAN search this forum for articles on normalization since this is a database forum. You can ALSO search the web for articles on DATABASE NORMALIZATION. You need to qualify it for a general web search because normalization is also used in chemistry, politics, diplomacy, mathematics, and medicine. If you go the web route, you might find articles in your preferred language, but in any case I would advise FIRST looking at articles from an .EDU domain, usually from colleges. They will focus on the academic side of the discussion and are less likely to try to sell you something. Once you get the idea, if you wanted to look at a couple of .COM domain entries, that is OK. They will just want to tell you about THEIR version of SQL or THEIR development environment.

The point of NORMALIZATION is to try to maintain purity of purpose for a given table. If a table describes items, it should not describe people or places. (That's a simplified way of looking at it.) It should also not describe ACTIONS even if those actions are related to the items, particularly if keeping a time-based history of actions is important.

Your question about "3 tables for 3 different kinds of systems" describes a situation that violates normalization by making a division of data where one should not be. If we use the Ford, Toyota, Ferrari model, then your top level table is really about automobiles. The table can SAY what kind of automobile it is, but it is always about automobiles. Ford, Toyota, and Ferrari all represent DATA in the automobile table, not separate tables.
 

lacampeona

Registered User.
Local time
Today, 07:08
Joined
Dec 28, 2015
Messages
392
Hello
Thank you for your explanation.
Can we talk here about normalization? I will also study that.

ok so you mean that I have to create 3 separate fields? ford, toyota, ferrari and all that in one table?table B?ok

now i have one field called system type and then here user choose which system he will use for the item. ( toyota, ford, ferrari)

ok. i create that in separate tables becouse every system has then different status?
so imagine:
item 1 system ford status relased
now i know that ford is relased and toyota and ferrari are still status new
if i put separate field and all in one table how i will know who is relased? toyota? ford? or ferrari? now i have one status in one table and from that i know that ford is relased.
if i put all 3 field in the same table and i have only one field status how i will know who is relased? i will have to create 3 statuses?
i will have mess? i will have one field filled and two fields empty? status for ford be relased and for toyota and ferrari new? users will be confused?
hmmmm
 

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Today, 00:08
Joined
Feb 28, 2001
Messages
27,148
Normalization is the process that lets you look at an object and say, what are its properties? I.e. how do I describe it? The item's record needs a unique and permanent identifier, which in this discussion will be AID. The other properties might not be unique, but the important takeaway is that one record describes one example of whatever it is that the table represents. We are saying, for discussion, that the table represents cars. So each record in A is one car.

Let's say you have your table A (describing cars) with fields like this:

A.AID - autonumber, LONG integer. Think of the name as "A's ID" but just shorten it so you type less. And besides, apostrophes don't work in field names very well. Using "ID" as the name would work but has no hint (to a casual reader) as to "an ID ... of what?"
A.AName - some kind of name for an object described in table A. This is "A's Name" but again, we shorten it. But we don't shorten it down to "Name" because that is a reserved word.
A.AType - text, for which the expected values will be Ford, Toyota, Ferrarri. "A's Type" but "Type" is another reserved word...
A.ABody - text, might be COUPE or SEDAN or SUV or PICKUP or 18-WHEELER-TRACTOR or FARM TRACTOR or GOLF CART ...
A.AColor - text, might be RED or BLUE or GREEN or FUSCIA or PUCE or UGLY BROWN or ...
A.....whatever else - but NOT the status.

When you want to work only on Fords, your query will include "WHERE A.AType = 'Ford' AND AID = {some number} AND ..." - but here is the important part. You don't pick a record purely because it is a Ford. You pick an item because of its AID - which HAPPENS to be a Ford. AND if it happens in that little WHERE clause that the AID doesn't select a Ford, you would get back nothing.

Note that if someday, someone sneaks in a Lexus, you merely type in "Lexus" and the rest of the car description. That is ALL you have to do - except for those things you think are unique.

Why isn't the status in A? Because unlike the properties shown in A, the status of the item changes based on an ACTION. Table A doesn't describe actions. It describes cars.

You want to track what happens to the cars. Based on "purity of purpose" (or perhaps you might prefer "purity of representation"), table A does NOT track actions. So you need a new table, called B in this example, to track what happens to the cars. You associate the actions to the right vehicle by tagging B records with the correct AID as a FOREIGN key, a pointer back to the object - the car - for which the action occurred. You track properties of the actions in the action table, B. Because records in B match up to a record in A, and can't exist if there IS no record in A to act as a reference, we say that A is the independent table and B is the dependent table. You will also see A as the parent and B as the child based on the preferences of whoever is writing.

In your B table, you have
B.AID - LONG integer, foreign key
B.BDate - date of most recent transaction. "B's Date" but "Date" is a reserved word... (by now I'm sure you get the idea.)
B.BStatus - text, status of most recent transaction
B.BWho - text, name of person performing the transaction
B.BMileage - number, mileage on the system as of the BDate
B.....whatever else describes the action.

That query we talked about earlier would JOIN A and B on the AID field. You can get information about the object from A and about the most recent action from B using that JOIN. If you use the matching AID record with the highest date (MAX(BDate)) you will know the current status of the item referenced by the number in AID. In the B table with a WHERE clause for a given AID, you would have the chronological history of status changes for that item selected by AID.

Think about what this would look like in a spreadsheet. Half the row would be about the car; the other half would be about an action. But if the next entry is about the same AID, half the next row would repeat the information about the car; the other half would be a new action. By splitting the tables (part of the normalization process), you isolate static vs. changing descriptions. This takes up less space and makes it easier to work with the parts.

Here is the reason you have to split the tables when normalizing. There is a rule that in a table, every property must depend uniquely on the prime key (in our example, AID). The Color and Type and Body depend on the AID. No problem there. BUT the status depends on AID and the date because when someone takes an action the status changes - based on the AID AND THE DATE! So leaving the status in the A table violates the property-dependence rule. Doesn't matter if you don't store the date. Whether it is stored or not, the status depends on more than just the AID field. And that's how you know you need another table. Talking again about spreadsheets, when you see yourself having to repeat data already in a previous row, that is a sign that you need to split the table when you convert the spreadsheet to Access.

This is the start of normalization. There is SO much more to discuss, but this gives you the idea of HOW you look at your data. I would strongly advise that you do some reading before you drive yourself crazy. (Note that such an action would be in the B table...)
 
Last edited:

Pat Hartman

Super Moderator
Staff member
Local time
Today, 01:08
Joined
Feb 19, 2002
Messages
43,233
You need to take off your spreadsheet hat and put on your relational database hat. You are visualizing columns with the names of data value rather than rows with a generic column name but whose value is a piece of data that represents the name of an automobile maker.

Think about it this way. How many automobile manufacturers are there in the world? I don't know but it has to be a couple of hundred given the number of countries that manufacture cars. So, if you could have autos from 20 different companies, you would make 20 columns. Then if you needed to support one more company, think about what you would have do change. How many forms, queries, and reports? How much code would need to be changed. Think about how you would identify what the manufacturer of a specific care would be done? Would you need 21 If statements to determine which column was "true"? Wouldn't it be easier if there were just ONE column named Manufacturer and it contained one of 21 values. You would have only a single field to deal with rather than 21. What would happen if you had to add a new manufacturer in the new table definition. No new columns, no modifications to forms to add additional controls, no changes to queries or reports or code. WOW! Typically, we would have a table named tblManufacturer. It would contain one row for each company. If you have to add a new one, you would add a row to this table and as if by magic, when you open your forms, a new item would automagically show up as a choice in your Manufacturer combo.

Another silly example. If you were making an employee table and you needed to record the names of children. How would you do that? There are a lot more potential names for children than there are for manufacturers. Would you still make them Sue, Marty, Paul, Alice? How would you store their birth dates? SueDOB, MartyDOB, PaulDOB, AliceDOB? How can employee #2 have different column names for his children? Or would you name them child1, child2, child3? Both solutions are wrong for different reasons.

It's not easy to switch the way you look at data but hopefully the silly child examples will open your eyes.
 

lacampeona

Registered User.
Local time
Today, 07:08
Joined
Dec 28, 2015
Messages
392
Helloooo
yes I think now I understand what I make wrong. I make wrong my design. I should never put the status in first table, table A. This was my big error.

this opens my eyes
The_Doc_Man
Why isn't the status in A? Because unlike the properties shown in A, the status of the item changes based on an ACTION. Table A doesn't describe actions. It describes cars.

and this opens my eyes
Pat Hartman:
You need to take off your spreadsheet hat and put on your relational database hat. You are visualizing columns with the names of data value rather than rows with a generic column name but whose value is a piece of data that represents the name of an automobile maker.

I didnt know that.
Thank you very much The_Doc_Man and Pat Hartman to write so good explanation so I could understand. I think if that read a little child 5 years old he will understand. So nice explanation with examples. Thank you.

One question: it is better then to make?
1. table A for items tbltems
2. table B for the usage tblUsage
3. table c with the statuses? tblStatus

or should I put the statuses in table B and no table C?
thanks again
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 01:08
Joined
Feb 19, 2002
Messages
43,233
Sometimes a silly, childlike example brings the point home quickly:)

We still don't know enough about your requirements to tell you the best structure. Maybe you can write a paragraph or two to describe the business process you are trying to model.

Regarding the question above, those three tables are a start. You also need one for manufacturer and possibly model if you go to that level of detail. The Status table defines the possible status codes. We don't know what status' you have aside from New and InUse. If it is just those two, most people would not bother with a separate table. They would use a Value list to define the options. A table is best if you have more than a few choices or if more might need to be added.
 

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Today, 00:08
Joined
Feb 28, 2001
Messages
27,148
One question: it is better then to make?
1. table A for items tbltems
2. table B for the usage tblUsage
3. table c with the statuses? tblStatus

or should I put the statuses in table B and no table C?

This becomes difficult to answer. Like Pat says, your tables will be based off of YOUR requirements. We cannot see your true requirements and thus cannot know the answer. In ALL database design projects, you must map the data to the real-life process, subject to normalization analysis. (And please note I gave you only the START of normalization concepts.)

From our discussion so far, your statuses only change as the result of some type of usage activity. Therefore, I would say "no table C" - but I don't know everything you want to do so understand that the answer could be that you DO need that table. We cannot advise you beyond the need to do a normalization exercise. That example I showed you about key dependency analysis is a good test for whether you need a new table or can use the existing table.

Note also that in practice, you might have SEVERAL tables related to what we discussed in order to drive either a list box or combo box. For example, you can have a "brand name" table for which the records are "Ford" and "Toyota" and "Ferrari" so you can use a combo to select that value. I jokingly listed some colors, and those could go into another table that would be used to drive a different combo. Then there were the body types, which could lead to another table to drive a third different combo. This is a case where what you wanted to do with the data would drive its form-factor. If you wanted to use combo-boxes to minimize errors (by only allowing folks to select available choices) then you would turn those options into a table of options. It's up to you as to what you want it to do and how you want to do it.
 

lacampeona

Registered User.
Local time
Today, 07:08
Joined
Dec 28, 2015
Messages
392
Ok so my story is next:

I am making database of some items used in pharmacy and chemistry.
I will have 4 different type of items. ( imagine: chair, mouse, window,pencils)

Items will be conected on different systems. I will have for now 3 different systems. ( ford, toyota, bmw). For now i have that systems in one field called system type and then user choose from combox which system he will use for that item? is that correct?

I must collect the data for the item, his usage and status, that mean for now 3 tables for one type of the item.?
tbl1 tblChair
tbl2 tblChairUsage
tbl3 tblChairStatus

and then also 3 tables for window? 3 tables for mouse? 3 tables for pencils?
hmmm i hope i am thinkking correct now. I need to have separated items becouse they are different. ?

i will have 6 different statuses of the item. ( new, in use, relased, sended, out of use, destroyed)

the story goes now:
user enter the item into database = tblChair
he will use some IDChair and make some usage ( here is going tblChairUsage), he will write what analyis he make on that chair, what liquid he use, when he did that, which notebook he used, what page, and then he will marked the status for the item. if he will make relaese analysis ( purpose of the usage) and if the item will pass he will say status relased, if item will not passed he will say in use... if he will change the status he will change the purpose of the item and he will say changing status and he will change the status to sended, so the user will know exatly if the item is relased or not if is sended or not.

I already have everything done. My problem was only that update status if I am doing that correct or not.
Now like i learn from here I will make some changes in database.
in first table i will delete the status field and I will make new table status.
I have to be careful what ID and PK i will chosee so then i will have correct relationship?
 

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Today, 00:08
Joined
Feb 28, 2001
Messages
27,148
This is getting a bit abstracted and harder to follow than it needs to be. Instead of tables and chairs and Fords and Toyotas, try using real category names. For what it's worth, I'm a PhD chemist and would understand analysis terms a LOT better than you might have first imagined.

The bit about using a combo box is, if you wanted to minimize the chance for someone to pick the wrong system or object or whatever, you make a list in a table and then can build a combo box to store either (a) the actual name or (b) a code associated with the actual name. Like we used to say about FORD, that was the coded short form of Fix, Overhaul, or Repair Daily.

I have to be careful what ID and PK i will chosee so then i will have correct relationship?

Absolutely true. In a relational database (like Access) you establish relationships between two tables by having a primary key in an independent table and a foreign key in a dependent table. So let's go back to your original "cars" and "actions"

You create a Car record and its AID is 1. Now to show that car #1 is new, you create an Action record with AID = 1 (to select Car #1) and action or status "NEW" to show that it is new and you include today's date to show WHEN it was new.

Sometime later, you check out Car #1 for inspection. So you create an Action record with AID = 1 (to again select Car #1) and action or status code "INSPECTION" plus the date. Now you know the status of Car #1 is that it has been inspected.

So in this simplified example, you relate the car to its status history by having the AID field in the Cars table and the same value in the foreign key field of the Actions table. That's how Access knows they are related - because they have a matching PK and FK.

Switching gears, it looks to me like you have a staging situation where a sample comes in and has a series of steps to go through from being NEW to being done, and from this viewpoint, it is a one-way street. Once you are no longer NEW you cannot go back to that status. And when you reach status DESTROYED then you are permanently done with that record (other than for its use in historical analysis such as summary reports). Is that closer to what you are really doing?
 

lacampeona

Registered User.
Local time
Today, 07:08
Joined
Dec 28, 2015
Messages
392
Switching gears, it looks to me like you have a staging situation where a sample comes in and has a series of steps to go through from being NEW to being done, and from this viewpoint, it is a one-way street. Once you are no longer NEW you cannot go back to that status. And when you reach status DESTROYED then you are permanently done with that record (other than for its use in historical analysis such as summary reports). Is that closer to what you are really doing?

Yes. That exatly is the goal of my database. When the item will be destroyed some day, user can not choose it and can not used for analysis.
I hope now I am in correct way with my plan.

I am enginner of chemistry and pharmaceutical tehnican. :) :giggle: and you are Phd Chemist very niceeeee. :)
 

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Today, 00:08
Joined
Feb 28, 2001
Messages
27,148
We have at least some technical language in common, then. As a bit of advice, switch to calling things by their real (or at least approximate) names. You might be surprised at how well we can do even without totally abstracted names of classes, objects, and categories.

And yes, the "Doc" in my screen name reflects my degree.
 

lacampeona

Registered User.
Local time
Today, 07:08
Joined
Dec 28, 2015
Messages
392
Hi again
I have a new problem.
Finally I managed to have correct updating status method. A lot of testing shows me that I have again new problem.
From you experts I learn and create a query that update my statuses. This works perfectly.

Like Arnelgp suggested me I have on Unload event on my form(frmUsage) the next code
Private Sub Form_Unload(Cancel As Integer)

CurrentDb.Execute "Update tblKolone2 Set StatusKolone = DLookup('LastOfStatus','qryItemStatusPrvaStran','KID = ' & [KID])"
CurrentDb.Execute "Update tblKolone2 Set StatusKolone = DLookup('LastOfOddelekLastnik','qryItemStatusPrvaStran','KID = ' & [KID])"
End Sub

Problem is how to manage now to how the primary status? How to revert status back?

When users first enter the item in database the item have status New. ( tblKolone2)
Then user go to the second form frmUsage and want to make some analysis. He start entering data and suddenly he say I will close the form. He did not enter data in status field. Here is now status field empty. he close the form.
Becouse here I have the code on unload event my status who was in the begining New go to empty field.

I need to show again status New if user dont fill all the fields and decide to close the form without saving.

I need to put new query on the Undo event form? Here I think Arnel also show me some example but I dont know I dont get the correct status back?
I try it but doesnt work?
hmm
what is best to do?
thank you
 

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Today, 00:08
Joined
Feb 28, 2001
Messages
27,148
Your pair of .Execute statements updates the same field - StatusKolone - to two different things, so the first update does nothing permanent. You could omit that statement and never see a difference in effect. That was, however, a comment in passing.

The REAL issue is that it sounds from your description that you updated the status away from NEW prematurely. You should NEVER allow a status to change until you know you have everything you need. Updating on-the-fly is dangerous because of the risk of connection losses, crashes, and people who incorrectly follow procedures. Before you allow the form to unload, you need to check whether the current record is self-consistent. That second form should decide if IT has enough to correctly update the record. If it does not, don't allow the update but instead use a Me.Undo in the Form_BeforeUpdate event. Don't allow the form to exit without either committing the change or canceling it (i.e. UNDO).

Remember that with event code in the second form, even though that form might be bound to a child table, you can run one of those CurrentDB.Execute statements to update the main record's status in the main table. And opening the second form is no biggie because the KID for the implied new record's foreign key is available, and HAS been available since you created the NEW record.

There is something to be said for having forms doing only limited things in order to keep each task relatively simple. There is a contrary philosophy that the details form would - at that moment of making the detailed updates - also know the correct status for the main form. And the philosophy there is "make the change where you know it will be good."

I understand that you have a complex problem. Getting it right can be like walking barefoot across a floor full of broken glass. No matter which way you go, things seem perilous. We've been there. It may not be helpful for meeting deadlines, but the only true solution is to pick your way slowly and carefully so you can avoid getting stuck. There is no substitute for careful analysis, no matter HOW much we would want to get the job done quickly.
 

lacampeona

Registered User.
Local time
Today, 07:08
Joined
Dec 28, 2015
Messages
392
Hi DocMan
Yes secod update statment is writen wrong, I was playing here and trying to create query who will show me first value entered in the table? And I didn managed nothing.. :confused:


Yes I know I have complex problem. When I start thinking ohh yees I finally managed correct status then I start testing and do every possible changes I notice ohh that is not good. If user will close the form without the saving record my status will not be correct.
If the user enters all the data in the form and close it then I have the correct status.
Having the correct status was my biggest problem. I was using differing approach using do sql. Now I am using query for that.

So thank you for you explanation. Now reading your explanation make sense how to do that.
Here bellow is my code on my forms before update event. So you mean I have to us Me.Undo here inside? Where exatly I have to put?

Private Sub Form_BeforeUpdate(Cancel As Integer)
If SaveYN = True Then
SaveYN = False
Else
Cancel = True
MsgBox "Kliknite na Shrani in shranite zapis.", vbOKOnly
Exit Sub
End If

If ValidateForm(Me, "required") = False Then
Cancel = True
End If

Call AuditData(Me)
If Me.NewRecord Then
Call AuditChanges("UporabaKID", "New")
Else
Call AuditChanges("UporabaKID", "Edit")
End If
End Sub
 

Users who are viewing this thread

Top Bottom