Update Another Tables Record (1 Viewer)

KadeFoster

Registered User.
Local time
Tomorrow, 06:01
Joined
Apr 7, 2012
Messages
67
Hey all,

I am trying to update a record in another table when i create an update in the current table. I finally figured out the SQL to get it to update for the selected record, but the problem i am having now is that it updates the previous Status not the one that i just set.

Code:
CurrentDb.Execute "UPDATE InspectionRequestT SET [InspectionStatus]='" & InspectionStatus & "' WHERE [InspectionRequestID] =" & InspectionRequestID

The image shows where i am updating the status. InspectionExplorerF and the other form InspectionListF is where i want it to update. Its like a delay update lol
Suggestions welcome :D

Capture.JPG
 

pbaldy

Wino Moderator
Staff member
Local time
Today, 13:01
Joined
Aug 30, 2003
Messages
36,126
What event is the code in? Use a variable and debug it so you can see what values are being seen:

 

MajP

You've got your good things, and you've got mine.
Local time
Today, 16:01
Joined
May 21, 2018
Messages
8,533
You did not show us the event. If you have not left the record then the value is not comitted. Try
Me.dirty = false
Before the update.
 

plog

Banishment Pending
Local time
Today, 15:01
Joined
May 11, 2011
Messages
11,646
UPDATE queries always give off a whiff of an improperly structured database. Add to it the smell that you are storing the same data in 2 different tables and I have to dig deeper into the cause of the odor:

Why are you updating data in another table instead of adding a record in that table? If the status on 11/11 was 'Pending' and on 12/12 you change it to 'In Progress', you lose the ability to find out when it was in a Pending status because you overwrote that data.

Why is the status stored in 2 places? Theoretically Table1 could show Pending but Table2 could show In Progress, is that something you want or should the 2 tables always have the same status?
 

KadeFoster

Registered User.
Local time
Tomorrow, 06:01
Joined
Apr 7, 2012
Messages
67
UPDATE queries always give off a whiff of an improperly structured database. Add to it the smell that you are storing the same data in 2 different tables and I have to dig deeper into the cause of the odor:

Why are you updating data in another table instead of adding a record in that table? If the status on 11/11 was 'Pending' and on 12/12 you change it to 'In Progress', you lose the ability to find out when it was in a Pending status because you overwrote that data.

Why is the status stored in 2 places? Theoretically Table1 could show Pending but Table2 could show In Progress, is that something you want or should the 2 tables always have the same status?
Am still learning, and yeah i agree duplication is not good.

I have one table where i keep the records for the Inspections and the main table keeps the information regarding that inspection.

What i was trying to do is Update the status of the Inspection Overview each time the user adds an update. But doing it the way that i have has created duplicate entries Status field.
 

plog

Banishment Pending
Local time
Today, 15:01
Joined
May 11, 2011
Messages
11,646
I would put this (and all other form issues) aside and focus on getting the right table structure.

Can you complete your database's Relationship Tool, expand all tables to show all fields and then post a screenshot back here? Or just upload a copy of your database with any personal infromation stripped.
 

KadeFoster

Registered User.
Local time
Tomorrow, 06:01
Joined
Apr 7, 2012
Messages
67
I would put this (and all other form issues) aside and focus on getting the right table structure.

Can you complete your database's Relationship Tool, expand all tables to show all fields and then post a screenshot back here? Or just upload a copy of your database with any personal infromation stripped.
My Database is split.
 

plog

Banishment Pending
Local time
Today, 15:01
Joined
May 11, 2011
Messages
11,646
Even better. Complete the back end Relationship tool or send a copy of that database.
 

KadeFoster

Registered User.
Local time
Tomorrow, 06:01
Joined
Apr 7, 2012
Messages
67
Even better. Complete the back end Relationship tool or send a copy of that database.
Well there you go, i didn't think that worked with a split database. Poor knowledge on my behalf.
 

Users who are viewing this thread

Top Bottom