Please help!!! Run-time error 3828 Cannot reference a table with a multi-valued field ...

%3CLINGO-SUB%20id%3D%22lingo-sub-2139779%22%20slang%3D%22en-US%22%3EPlease%20help!!!%20Run-time%20error%203828%20Cannot%20reference%20a%20table%20with%20a%20multi-valued%20field%20...%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2139779%22%20slang%3D%22en-US%22%3E%3CP%3E%3CEM%3EI%20have%20a%20form%20that%20passes%20a%20string%20to%20a%20query.%26nbsp%3B%20From%20the%20form%2C%20I%20want%20to%20convert%20the%20query%20results%20to%20a%20csv%20file.%26nbsp%3B%20I%20have%20checked%20several%20posts%20on%20this%20subject%20and%20they%20don't%20seem%20to%20have%20any%20problems%20using%20the%20DoCmd%20statement...I%20am%20posting%20my%20code%20below.%3C%2FEM%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EPrivate%20Sub%20Toggle15_Click()%3C%2FP%3E%3CP%3EDim%20QueryName%20As%20String%3CBR%20%2F%3EDim%20ReportName%20As%20String%3CBR%20%2F%3EDim%20SaveLocation%20As%20String%3CBR%20%2F%3EDim%20DateFormater%20As%20String%3CBR%20%2F%3EDim%20FileNameFormat%20As%20String%3CBR%20%2F%3EDim%20Project%20As%20String%3CBR%20%2F%3EDim%20Location%20As%20String%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EQueryName%20%3D%20%22qryConvert%22%3CBR%20%2F%3EDateFormater%20%3D%20Format(Date%2C%20%22MMDDYY%22)%3CBR%20%2F%3EReportName%20%3D%20%22ICAM%20Sustainment%22%3CBR%20%2F%3EFileNameFormat%20%3D%20ReportName%20%26amp%3B%20%22%20%22%20%26amp%3B%20DateFormater%20%26amp%3B%20%22.csv%22%3C%2FP%3E%3CP%3EProject%20%3D%20DLookup(%22ProjectDescription%22%2C%20%22tbl_Project%22%2C%20%22PID%20%3D%22%20%26amp%3B%20ProjectDescription)%3CBR%20%2F%3ELocation%20%3D%20DLookup(%22Location%22%2C%20%22tbl_Location%22%2C%20%22LID%20%3D%22%20%26amp%3B%20SiteLocation)%3CBR%20%2F%3EDoCmd.OpenQuery%20QueryName%2C%20acViewNormal%2C%20acEdit%3CBR%20%2F%3EDoCmd.TransferText%20acExportDelim%2C%20%2C%20QueryName%2C%20Text24%20%26amp%3B%20%22%5C%22%20%26amp%3B%20Location%20%26amp%3B%20%22_%22%20%26amp%3B%20Project%20%26amp%3B%20FileNameFormat%2C%20True%3C%2FP%3E%3CP%3EMsgBox%20%22Export%20is%20Complete!%22%3C%2FP%3E%3CP%3EEnd%20Sub%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CEM%3EI%20can't%20seem%20to%20find%20out%20what%20in%20the%20query%20is%20the%20problem.%26nbsp%3B%20I%20have%20a%20simple%20query%20with%20a%20lookup%20function%20for%20one%20value%20that%20is%20passed%20from%20a%20form...to%20select%20the%20records...The%20pic%20below%20shows%20where%20the%20code%20stops%20and%20the%20error%20message%20I%20get....Run-time%20error%203828%20Cannot%20reference%20a%20table%20with%20a%20multi-valued%20field%20using%20an%20IN%20clause%20that%20refers%20to%20another%20database.%3C%2FEM%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22bbalzer_2-1613495893163.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F255274i4F534535BC1FE37F%2Fimage-size%2Fmedium%3Fv%3D1.0%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%22bbalzer_2-1613495893163.png%22%20alt%3D%22bbalzer_2-1613495893163.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22bbalzer_1-1613495581300.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F255273iB35CA3C435DB7B5B%2Fimage-size%2Fmedium%3Fv%3D1.0%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%22bbalzer_1-1613495581300.png%22%20alt%3D%22bbalzer_1-1613495581300.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3Ethanks%20in%20advance.....%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-2139779%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3E2016%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EAccess%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2139911%22%20slang%3D%22en-US%22%3ERe%3A%20Please%20help!!!%20Run-time%20error%203828%20Cannot%20reference%20a%20table%20with%20a%20multi-valued%20field%20...%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2139911%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F968456%22%20target%3D%22_blank%22%3E%40bbalzer%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3EProblems%20like%20this%20are%20part%20of%20the%20reason%20most%20experienced%20Access%20developers%20strongly%20encourage%20NOT%20using%20multi-value%20fields%20in%20tables.%20They%20are%20like%20sugar%20cubes%2C%20really%20sweet%20at%20first%2C%20but%20sooner%20or%20later%20you%20realize%20eating%20cubed%20sugar%20is%20not%20a%20good%20plan%20if%20you%20value%20your%20health.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThe%20problem%20is%20not%20the%20DoCmd%20statement.%20The%20problem%20is%20the%20method%20you%20have%20to%20use%20to%20extract%20the%20values%20from%20the%20items%20in%20the%20MVF.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EIt's%20possible%2C%20but%20it%20remains%20a%20second-tier%20approach.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EYou%20might%20find%20some%20useful%20information%20%3CA%20href%3D%22https%3A%2F%2Fsupport.microsoft.com%2Fen-us%2Foffice%2Fusing-lookup-and-multivalued-fields-in-queries-6f64f92d-659f-411c-9503-b6624e1e323a%22%20target%3D%22_self%22%20rel%3D%22noopener%20noreferrer%22%3Ein%20this%20documentation.%3C%2FA%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2139965%22%20slang%3D%22en-US%22%3ERe%3A%20Please%20help!!!%20Run-time%20error%203828%20Cannot%20reference%20a%20table%20with%20a%20multi-valued%20field%20...%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2139965%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F126074%22%20target%3D%22_blank%22%3E%40George%20Hepworth%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3ESo%20I%20guess%20I%20should%20delete%20the%20lookup%20fields%3F%26nbsp%3B%20These%20fields%20are%20single%20value%20fields%20per%20record%20with%20no%20user%20entries.%26nbsp%3B%20Would%20dropdown%20list%20eliminate%20the%20multi-value%20issue%3F%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EAny%20insights%20would%20be%20appreciated...%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3Ethanks%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2140070%22%20slang%3D%22en-US%22%3ERe%3A%20Please%20help!!!%20Run-time%20error%203828%20Cannot%20reference%20a%20table%20with%20a%20multi-valued%20field%20...%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2140070%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F968456%22%20target%3D%22_blank%22%3E%40bbalzer%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ELookup%20fields%20fall%20into%20the%20same%20%22sugar%20cube%22%20category.%20We%20are%20talking%20about%20standard%20table%20design%20versus%20(what%20I%20think%20of%20as%20)%20eye%20candy%20design%2C%20to%20continue%20with%20the%20%22too%20sweet%22%20metaphor.%26nbsp%3B%3C%2FP%3E%3CP%3ECreate%20related%20tables%20where%20appropriate%20with%20an%20appropriate%20one-to-many%20relationship%20and%20store%20only%20the%20Foreign%20Keys%20in%20the%20related%20table.%26nbsp%3B%3C%2FP%3E%3CP%3EAnother%20way%20to%20look%20at%20it%20is%20that%20things%20like%20MVFs%20and%20Lookups%20are%20closely%20tied%20to%20tables%20as%20interface%20objects%20rather%20than%20data%20storage%20objects.%20In%20reality%2C%20users%20shouldn't%20be%20looking%20at%2C%20or%20directly%20touching%20tables%20anyway.%26nbsp%3B%3C%2FP%3E%3CP%3EI%20try%20not%20to%20be%20too%20dogmatic%20about%20it%20because%20I%20understand%20that%20everyone%20has%20to%20make%20such%20decisions%20for%20themselves.%20However%2C%20my%20recommendation%20is%20always%20going%20to%20be%20to%20stick%20as%20close%20as%20possible%20to%20solid%20table%20design%20principles.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2140074%22%20slang%3D%22en-US%22%3ERe%3A%20Please%20help!!!%20Run-time%20error%203828%20Cannot%20reference%20a%20table%20with%20a%20multi-valued%20field%20...%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2140074%22%20slang%3D%22en-US%22%3Ethank%20you%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2143061%22%20slang%3D%22en-US%22%3ERe%3A%20Please%20help!!!%20Run-time%20error%203828%20Cannot%20reference%20a%20table%20with%20a%20multi-valued%20field%20...%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2143061%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F968456%22%20target%3D%22_blank%22%3E%40bbalzer%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20went%20through%20the%20table%20and%20removed%20all%20of%20the%20lookup%20fields.%26nbsp%3B%20I%20am%20still%20getting%20the%20same%20error%20message.%26nbsp%3B%20What%20is%20confusing%20me%20is%20even%20before%20the%20lookup%20fields%20were%20removed%20and%20recreated%2C%20the%20query%20would%20retrieve%20the%20data%20and%20I%20could%20convert%20query%20results%20to%20an%20excel%20file%20manually%20and%20then%20manually%20save%20as%20a%20CSV%20with%20no%20problem%2C%20just%20not%20programmatically...any%20ideas%3F%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2143143%22%20slang%3D%22en-US%22%3ERe%3A%20Please%20help!!!%20Run-time%20error%203828%20Cannot%20reference%20a%20table%20with%20a%20multi-valued%20field%20...%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2143143%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F968456%22%20target%3D%22_blank%22%3E%40bbalzer%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThe%20same%20error%20message%20even%20though%20there%20are%20no%20longer%20any%20MVF%20fields%20in%20the%20tables%3F%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2143148%22%20slang%3D%22en-US%22%3ERe%3A%20Please%20help!!!%20Run-time%20error%203828%20Cannot%20reference%20a%20table%20with%20a%20multi-valued%20field%20...%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2143148%22%20slang%3D%22en-US%22%3Eyes..%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2143162%22%20slang%3D%22en-US%22%3ERe%3A%20Please%20help!!!%20Run-time%20error%203828%20Cannot%20reference%20a%20table%20with%20a%20multi-valued%20field%20...%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2143162%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F968456%22%20target%3D%22_blank%22%3E%40bbalzer%3C%2FA%3E%26nbsp%3BThat%20suggests%20there%20is%20another%20problem%20in%20that%20query.%20In%20the%20screenshot%2C%20we%20see%20only%20the%20query%20name.%20Can%20you%20open%20the%20query%20in%20SQL%20view%20and%20copy%20the%20SQL%20out%20and%20paste%20here%3F%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2143168%22%20slang%3D%22en-US%22%3ERe%3A%20Please%20help!!!%20Run-time%20error%203828%20Cannot%20reference%20a%20table%20with%20a%20multi-valued%20field%20...%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2143168%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F126074%22%20target%3D%22_blank%22%3E%40George%20Hepworth%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ESELECT%20tbl_AssetUpdate.ID%2C%20tbl_AssetUpdate.ProjectNo%2C%20tbl_AssetUpdate.RPUID%2C%20tbl_AssetUpdate.UnitID%2C%20tbl_AssetUpdate.UDID%2C%20tbl_AssetUpdate.Site%2C%20tbl_AssetUpdate.GISLayer%2C%20tbl_AssetUpdate.GISObjectID%2C%20tbl_AssetUpdate.Personnel%2C%20tbl_AssetUpdate.DateSub%2C%20tbl_AssetUpdate.SME%2C%20tbl_AssetUpdate.SMEPhone%2C%20tbl_AssetUpdate.InstallationID%2C%20tbl_AssetUpdate.ServiceStatus%2C%20tbl_AssetUpdate.FeatureID%2C%20tbl_AssetUpdate.UpdateType%2C%20tbl_AssetUpdate.LongDescription%2C%20tbl_AssetUpdate.YearInstalled%2C%20tbl_AssetUpdate.SizeLength%2C%20tbl_AssetUpdate.PhysicalLocation%2C%20tbl_AssetUpdate.InspectedBy%2C%20tbl_AssetUpdate.InspectedDate%2C%20tbl_AssetUpdate.Manufacturer%2C%20tbl_AssetUpdate.ModelNo%2C%20tbl_AssetUpdate.SerialNo%2C%20tbl_AssetUpdate.%5BVoltage%20Level%5D%2C%20tbl_AssetUpdate.%5BConduit%20Size%5D%2C%20tbl_AssetUpdate.NoConduits%2C%20tbl_AssetUpdate.NoWires%2C%20tbl_AssetUpdate.ConduitMaterial%2C%20tbl_AssetUpdate.PipeMaterial%2C%20tbl_AssetUpdate.PipeSize%2C%20tbl_AssetUpdate.DownstreamInvert%2C%20tbl_AssetUpdate.TankType%2C%20tbl_AssetUpdate.RemainingSL%2C%20tbl_AssetUpdate.%5BWO%20No%5D%2C%20tbl_AssetUpdate.Comments%2C%20tbl_AssetUpdate.WorkOrderType%2C%20tbl_AssetUpdate.NetworkType%2C%20tbl_AssetUpdate.NetworkSubType%2C%20tbl_AssetUpdate.Disposition%2C%20tbl_AssetUpdate.%5BEquipment%20Type%5D%2C%20tbl_AssetUpdate.WaterType%2C%20tbl_AssetUpdate.%5BGas%20Type%5D%2C%20tbl_AssetUpdate.Attachments%2C%20tbl_AssetUpdate.Completed%2C%20tbl_AssetUpdate.DateCompleted%2C%20tbl_AssetUpdate.UpdatedBy%2C%20tbl_AssetUpdate.UpdateStatus%2C%20tbl_AssetUpdate.DShtNo%2C%20tbl_AssetUpdate.DWGNo%2C%20tbl_AssetUpdate.PID%3CBR%20%2F%3EFROM%20tbl_AssetUpdate%3CBR%20%2F%3EWHERE%20(((tbl_AssetUpdate.ProjectNo)%3D%5BForms%5D!%5BfrmSiteSelectConvert%5D!%5BProjectNo%5D))%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2143191%22%20slang%3D%22en-US%22%3ERe%3A%20Please%20help!!!%20Run-time%20error%203828%20Cannot%20reference%20a%20table%20with%20a%20multi-valued%20field%20...%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2143191%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F968456%22%20target%3D%22_blank%22%3E%40bbalzer%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThank%20you.%20And%20I%20think%20we%20were%20sent%20down%20the%20wrong%20rabbit%20hole%20by%20that%20error%20message%2C%20at%20least%20in%20part.%26nbsp%3B%3C%2FP%3E%3CP%3EWhile%20my%20recommendations%20regarding%20MVF%20and%20Lookup%20fields%20in%20tables%20are%20the%20same%2C%20there%20is%20also%20another%20%3CSTRIKE%3Eissue%3C%2FSTRIKE%3E%26nbsp%3Bproblem%20at%20work%20in%20this%20query%20in%20VBA.%20I%20should%20have%20considered%20that%20earlier.%3C%2FP%3E%3CP%3EI%20don't%20think%20the%20problem%20is%20the%20WHERE%20clause%2C%20but%20as%20a%20test%2C%20can%20you%20create%20a%20copy%20of%20the%20query%20with%20a%20hard-coded%20ProjectNo%20instead%20of%20the%20form%20control%20reference%3F%3C%2FP%3E%3CP%3E%3CSPAN%3EWHERE%20(((tbl_AssetUpdate.ProjectNo)%3D12345))%3B%20--%20Use%20a%20valid%20ProjectNo%20in%20your%20project%20table%2C%20of%20course.%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%3ESame%20error%3F%26nbsp%3B%3C%2FSPAN%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2143209%22%20slang%3D%22en-US%22%3ERe%3A%20Please%20help!!!%20Run-time%20error%203828%20Cannot%20reference%20a%20table%20with%20a%20multi-valued%20field%20...%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2143209%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F126074%22%20target%3D%22_blank%22%3E%40George%20Hepworth%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22bbalzer_0-1613575382480.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F255523i23E5D3028AF52026%2Fimage-size%2Fmedium%3Fv%3D1.0%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%22bbalzer_0-1613575382480.png%22%20alt%3D%22bbalzer_0-1613575382480.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3EShouldn't%20the%20object%20be%20the%20qryconvert%3F%26nbsp%3B%20It%20seems%20like%20its%20looking%20for%20the%20csv%20file%3F%3C%2FP%3E%3C%2FLINGO-BODY%3E
Occasional Contributor

I have a form that passes a string to a query.  From the form, I want to convert the query results to a csv file.  I have checked several posts on this subject and they don't seem to have any problems using the DoCmd statement...I am posting my code below.

 

 

Private Sub Toggle15_Click()

Dim QueryName As String
Dim ReportName As String
Dim SaveLocation As String
Dim DateFormater As String
Dim FileNameFormat As String
Dim Project As String
Dim Location As String

 

QueryName = "qryConvert"
DateFormater = Format(Date, "MMDDYY")
ReportName = "ICAM Sustainment"
FileNameFormat = ReportName & " " & DateFormater & ".csv"

Project = DLookup("ProjectDescription", "tbl_Project", "PID =" & ProjectDescription)
Location = DLookup("Location", "tbl_Location", "LID =" & SiteLocation)
DoCmd.OpenQuery QueryName, acViewNormal, acEdit
DoCmd.TransferText acExportDelim, , QueryName, Text24 & "\" & Location & "_" & Project & FileNameFormat, True

MsgBox "Export is Complete!"

End Sub

 

I can't seem to find out what in the query is the problem.  I have a simple query with a lookup function for one value that is passed from a form...to select the records...The pic below shows where the code stops and the error message I get....Run-time error 3828 Cannot reference a table with a multi-valued field using an IN clause that refers to another database.

 

bbalzer_2-1613495893163.png

 

 

bbalzer_1-1613495581300.png

 

thanks in advance.....

 

43 Replies

@bbalzer 

Problems like this are part of the reason most experienced Access developers strongly encourage NOT using multi-value fields in tables. They are like sugar cubes, really sweet at first, but sooner or later you realize eating cubed sugar is not a good plan if you value your health.

 

The problem is not the DoCmd statement. The problem is the method you have to use to extract the values from the items in the MVF.

 

It's possible, but it remains a second-tier approach.

 

You might find some useful information in this documentation.

 

@George Hepworth 

So I guess I should delete the lookup fields?  These fields are single value fields per record with no user entries.  Would dropdown list eliminate the multi-value issue?

 

Any insights would be appreciated...

 

thanks

@bbalzer 

 

Lookup fields fall into the same "sugar cube" category. We are talking about standard table design versus (what I think of as ) eye candy design, to continue with the "too sweet" metaphor. 

Create related tables where appropriate with an appropriate one-to-many relationship and store only the Foreign Keys in the related table. 

Another way to look at it is that things like MVFs and Lookups are closely tied to tables as interface objects rather than data storage objects. In reality, users shouldn't be looking at, or directly touching tables anyway. 

I try not to be too dogmatic about it because I understand that everyone has to make such decisions for themselves. However, my recommendation is always going to be to stick as close as possible to solid table design principles.

@bbalzer 

I went through the table and removed all of the lookup fields.  I am still getting the same error message.  What is confusing me is even before the lookup fields were removed and recreated, the query would retrieve the data and I could convert query results to an excel file manually and then manually save as a CSV with no problem, just not programmatically...any ideas?

@bbalzer 

The same error message even though there are no longer any MVF fields in the tables?

@bbalzer That suggests there is another problem in that query. In the screenshot, we see only the query name. Can you open the query in SQL view and copy the SQL out and paste here? 

@George Hepworth 

 

SELECT tbl_AssetUpdate.ID, tbl_AssetUpdate.ProjectNo, tbl_AssetUpdate.RPUID, tbl_AssetUpdate.UnitID, tbl_AssetUpdate.UDID, tbl_AssetUpdate.Site, tbl_AssetUpdate.GISLayer, tbl_AssetUpdate.GISObjectID, tbl_AssetUpdate.Personnel, tbl_AssetUpdate.DateSub, tbl_AssetUpdate.SME, tbl_AssetUpdate.SMEPhone, tbl_AssetUpdate.InstallationID, tbl_AssetUpdate.ServiceStatus, tbl_AssetUpdate.FeatureID, tbl_AssetUpdate.UpdateType, tbl_AssetUpdate.LongDescription, tbl_AssetUpdate.YearInstalled, tbl_AssetUpdate.SizeLength, tbl_AssetUpdate.PhysicalLocation, tbl_AssetUpdate.InspectedBy, tbl_AssetUpdate.InspectedDate, tbl_AssetUpdate.Manufacturer, tbl_AssetUpdate.ModelNo, tbl_AssetUpdate.SerialNo, tbl_AssetUpdate.[Voltage Level], tbl_AssetUpdate.[Conduit Size], tbl_AssetUpdate.NoConduits, tbl_AssetUpdate.NoWires, tbl_AssetUpdate.ConduitMaterial, tbl_AssetUpdate.PipeMaterial, tbl_AssetUpdate.PipeSize, tbl_AssetUpdate.DownstreamInvert, tbl_AssetUpdate.TankType, tbl_AssetUpdate.RemainingSL, tbl_AssetUpdate.[WO No], tbl_AssetUpdate.Comments, tbl_AssetUpdate.WorkOrderType, tbl_AssetUpdate.NetworkType, tbl_AssetUpdate.NetworkSubType, tbl_AssetUpdate.Disposition, tbl_AssetUpdate.[Equipment Type], tbl_AssetUpdate.WaterType, tbl_AssetUpdate.[Gas Type], tbl_AssetUpdate.Attachments, tbl_AssetUpdate.Completed, tbl_AssetUpdate.DateCompleted, tbl_AssetUpdate.UpdatedBy, tbl_AssetUpdate.UpdateStatus, tbl_AssetUpdate.DShtNo, tbl_AssetUpdate.DWGNo, tbl_AssetUpdate.PID
FROM tbl_AssetUpdate
WHERE (((tbl_AssetUpdate.ProjectNo)=[Forms]![frmSiteSelectConvert]![ProjectNo]));

@bbalzer 

 

Thank you. And I think we were sent down the wrong rabbit hole by that error message, at least in part. 

While my recommendations regarding MVF and Lookup fields in tables are the same, there is also another issue problem at work in this query in VBA. I should have considered that earlier.

I don't think the problem is the WHERE clause, but as a test, can you create a copy of the query with a hard-coded ProjectNo instead of the form control reference?

WHERE (((tbl_AssetUpdate.ProjectNo)=12345)); -- Use a valid ProjectNo in your project table, of course.

Same error? 

@George Hepworth 

 

bbalzer_0-1613575382480.png

Shouldn't the object be the qryconvert?  It seems like its looking for the csv file?

@bbalzer 

Yes, that is exactly what is happening, I think. And it does reveal the problem more clearly, thank goodness. Do you have this csv linked to your accdb? That's a remarkably long file name, BTW, It occurs to me to wonder if perhaps the number of characters exceeds some limit. It also occurs to me to wonder if the path to that csv is specified properly.

 

 

@bbalzer 

Sorry, I overlooked your last question. I assumed that the query is based, at least in part on that missing .csv file. Is the table in the query linked to it? Somehow, something is referencing it.

@George Hepworth 

 

Since the query is not converted to a CSV file until the DoCmd code is completed, why would it be looking for a CSV file?  I am still confused on how it works fine when manually executed, but with the program code it bombs...

@bbalzer I can't see the internal workings in that accdb, so all I can do is guess from experience. Are you saying that the csv in the error message is intended to be the RESULT of the export, and not one of the sources, i.e. not a linked table?

If so, then I'm going to lean even stronger to a length problem in the file name. Try, as a test, something very short, like "Test.csv" for the output file instead.

@George Hepworth 

 

yes, the desired output is the query converted to a CSV file.  I tried to shorten the file name, but it didn't have any effect.  Should the conversion be a two-step process?  I had originally went that direction and was able to have the query programmatically saved as a .xlsx file.  I was in the process of trying to rename the file as a csv file, until I saw a comment about using the doCmd transfertext post, seemed so easy.   The original code used a saved export to excel and that portion worked just fine, it was the renaming that buried me...

@bbalzer 

 

Wow, We've really strayed away from that initial error message. 

 

So, if it works as an export to .xlsx, then it does seem like the problem is the file format piece.

I'm of two minds.

 

If you can get to the result you want by exporting the .xlsx and then converting that to a .csv, then that would be the path of expediency and "making it work".

If you can get the desired result in a single steps, then that is certainly more elegant.

 

Let me do a bit of investigation on that aspect. Unfortunately, I think we really got mislead by the error messages, and that's at least partly my fault for not thinking that way.

 

@bbalzer 

How about removing that colon from the file name. I can break my export by inserting a : into the file name to be created. It gives me a different error message, but the behavior seems to be the same.

In fact, now that I think about it, that might be resolved by Windows along the lines of the colon in a drive reference, c:\path and that would break it. Does that make a difference in your environment?