Avatar of pdvsa
pdvsa
Flag for United States of America asked on

Update and Dlookup

Hello experts,

I have a combo box (cboFacilityType) on a form (underlying table and field: tblDraws_Details.FacilityType) and after I update cboFacilityType I need to update another field in the same record (tblDraws_Details.ID_facility)  but I need to update to the same value where tblFacilityCommitments.FacilityType=tblDraws_Details.FacilityType)

I basically I need to update [tblDraws_Details.ID_facility] where [tblFacilityCommitments.FacilityType = tblDraws_Details.FacilityType

I think it would look something like this (but it it doesnt update to anything) :
FYI:  

Private Sub cboFacilityType_AfterUpdate()

    Me.ID_facility = DLookup("FacilityType", "tblFacility_Commitments", "FacilityType=" & [FacilityType].Value & "")
                                                                                                                                                     '   ^^^possibly facilitytype.column(1)-didnt work tho
End Sub

Possibly InsertInto would be another way to do this instead of dlookup because I believe Dlookup slows the db.
thank you
Microsoft Access

Avatar of undefined
Last Comment
Jim Dettman (EE MVE)

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
Jim Dettman (EE MVE)

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
pdvsa

ASKER
Thank you.  
your #1 worked:
Me.ID_facility = DLookup("ID_facility", "tblFacility_Commitments", "FacilityType=" & Me.[cboFacilityType])

I also modified your suggestion from column(1) to column (0) as the ID on the cbo is in the first column.  After I did this, it worked just as the above:
Me.ID_facility = DLookup("ID_facility", "tblFacility_Commitments", "FacilityType=" & Me.[cboFacilityType].Column(0))

thank you very much for your expert assistance.
pdvsa

ASKER
Also, I have not used the site in over a year.  I use to award points.   I assume points are no longer awarded.  Let me know if I have missed something.
Jim Dettman (EE MVE)

A lot has changed recently (just this week in fact), but points are still awarded,   Just mark my comment as best solution.

Jim.
I started with Experts Exchange in 2004 and it's been a mainstay of my professional computing life since. It helped me launch a career as a programmer / Oracle data analyst
William Peck