Forum Discussion
Maxine14062
Feb 19, 2025Brass Contributor
Query re: OLE Object
I need to write a query to update an OLEObject field on a form (Forms!ScheduleFormCont!ColorTextBox), based on a table with the same OLEObject field (SCHEDULE.ColorTextBox). I am updating the form fi...
Maxine14062
Feb 20, 2025Brass Contributor
Thank you sooooooo much!
arnel_gp
Feb 21, 2025Steel Contributor
Using Update query on the same record you are Editing on the form is not a good idea.
Because the Update query took place when the form is Dirty, therefore MS may complain that you don't have the latest record on the view (or someone ahead of you just saved an update).
What you can do is add code to ColorText BeforeUpdate Event:
Private Sub ColorText_BeforeUpdate(Cancel As Integer)
Me.ColorTextbox = DLookup("Color", "ColorsTable", "ColorName = '" & Me.ColorText & "'")
End Sub
or you can Create a Query that will link both tables and use the Query as the Recordsource of your form, in that way you can remove the ColorTextbox (ole object field) and there is no need for any update query. Plus your tables are now Normalized.
SELECT Schedule.ColorText, Schedule.SONo, ColorsTable.Color
FROM Schedule LEFT JOIN ColorsTable
ON Schedule.ColorText = ColorsTable.ColorName;