R
Robert5833
Good day all;
Access 2007, 1 Gb RAM
I have looked for but cannot find an example of an UPDATE SQL string for a
VBA procedure with a WHERE clause. If I can’t use a WHERE clause in an UPDATE
SQL then I’ll have to devise a different solution.
Otherwise, here is what I’m trying to do:
I have two tables; one to hold unique items, and one to hold records that
relate to the unique item.
Table
1) tblMotor (unique item; no duplicates; Primary Key fldMotorID)
Fields
fldMotorID (autonumber; no duplicates)
fldMotorName (text; yes duplicates)
fldMotorHours (number; double, represents current accumulated motor hours,
yes duplicates)
Table
2) tblPart (related to tblMotor thru foreign key; duplicates allowed;
Primary Key fldPartID)
Fields
fldPartID (autonumber; no duplicates)
fldPartName (text; yes duplicates)
fldPartHours (number; double; represents current accumulated hours, yes
duplicates)
Forms (one only)
frmMotorStatus; Record Source, tblMotor
Text box; tboMotorID, bound on fldMotorID
Text box; tboMotorHours, bound on fldMotorHours
Unbound text box; tboAddMotorHours, a data entry point for “new†current
Motor Hours
When I enter a new current motor hour value on the form I want the After
Update event to execute the VBA SQL to subtract the difference between the
tboAddMotorHours and tboMotorHours, and add (presumably "UPDATE") the result
as an incremental to the existing value in all of the related records in
tblPart, using the tblMotorID as the unique record identifier.
The reason for not simply making current part hours the same as the current
motor hours is that each record in tblPart can be on a different hour level
when part is installed or replaced. Once installed, part hours are accrued on
the basis of the motor accumulated time.
I hope this description is clear and accurate enough; and I don’t have any
code written for this piece of my puzzle yet.
Can this even be done with a VBA SQL and UPDATE with WHERE clause in the
string?
As always, I appreciate any help or suggestions on building this SQL, or a
better approach than what I’ve dreamt up…
Thank you in advance,
RL
Access 2007, 1 Gb RAM
I have looked for but cannot find an example of an UPDATE SQL string for a
VBA procedure with a WHERE clause. If I can’t use a WHERE clause in an UPDATE
SQL then I’ll have to devise a different solution.
Otherwise, here is what I’m trying to do:
I have two tables; one to hold unique items, and one to hold records that
relate to the unique item.
Table
1) tblMotor (unique item; no duplicates; Primary Key fldMotorID)
Fields
fldMotorID (autonumber; no duplicates)
fldMotorName (text; yes duplicates)
fldMotorHours (number; double, represents current accumulated motor hours,
yes duplicates)
Table
2) tblPart (related to tblMotor thru foreign key; duplicates allowed;
Primary Key fldPartID)
Fields
fldPartID (autonumber; no duplicates)
fldPartName (text; yes duplicates)
fldPartHours (number; double; represents current accumulated hours, yes
duplicates)
Forms (one only)
frmMotorStatus; Record Source, tblMotor
Text box; tboMotorID, bound on fldMotorID
Text box; tboMotorHours, bound on fldMotorHours
Unbound text box; tboAddMotorHours, a data entry point for “new†current
Motor Hours
When I enter a new current motor hour value on the form I want the After
Update event to execute the VBA SQL to subtract the difference between the
tboAddMotorHours and tboMotorHours, and add (presumably "UPDATE") the result
as an incremental to the existing value in all of the related records in
tblPart, using the tblMotorID as the unique record identifier.
The reason for not simply making current part hours the same as the current
motor hours is that each record in tblPart can be on a different hour level
when part is installed or replaced. Once installed, part hours are accrued on
the basis of the motor accumulated time.
I hope this description is clear and accurate enough; and I don’t have any
code written for this piece of my puzzle yet.
Can this even be done with a VBA SQL and UPDATE with WHERE clause in the
string?
As always, I appreciate any help or suggestions on building this SQL, or a
better approach than what I’ve dreamt up…
Thank you in advance,
RL