简体   繁体   中英

Access 2010 SQL Update cmd

I'm having some difficulty with an Update statement.

UPDATE DownPeriod 
SET 
DownPeriod.EquipmentID = ? ?? ?? ? ??  ?? ? ?,
DownPeriod.DownDate = Forms!Edit!EditDownDateBox,
DownPeriod.DownTime = Forms!Edit!EditDownTimeBox, 
DownPeriod.[UpDate] = Forms!Edit!EditUpDateBox, 
DownPeriod.UpTime = Forms!Edit!EditUpTimeBox, 
DownPeriod.isScheduled = Forms!Edit!EditSchedCheck, 
DownPeriod.isUnscheduled = Forms!Edit!EditUnschedCheck, 
DownPeriod.Comments = Forms!Edit!EditCommentsDropDown
WHERE DownPeriod.DownPeriodID =Forms!Edit!RecordHistorySubform.Form!DownPeriodID;

Where the question marks are is where im having difficulty, and am not sure what to put.

Everything else about the update will work if I remove that statement so I know im on the right track. The difference with the EquipmentID is that I'm getting this value based on an input for another table entry. To elaborate the user chooses an Equipment Title, which is another field in my Equip Table that will relate to a unique ID.

So far I have tried DLOOKUP("[EquipmentID]", "Equipment", "[Title] = Forms!Edit!EditEquipmentDropDown") Select statment and using inner join I'm at a loss and need help plz! Thank you!

If it is a new unique id you need an INSERT. If it already exists you should include it as part of your WHERE clause.

WHERE DownPeriod.DownPeriodID =Forms!Edit!RecordHistorySubform.Form!DownPeriodID AND DownPeriod.EquipmentID = Forms!Edit!EditEquipmentDropDown;

You say that the user is selecting the title from a dropdown. The dropdown should have a row source on these lines:

  SELECT ID, Title FROM Equipment

With ID as a hidden column. Your update should then be:

 DownPeriod.EquipmentID = Forms!Edit!EditTitleDropDown

As an aside, I suspect you are doing a lot more work that you need to do to make an MS Access form work.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM