我有一个表单,其中我添加了一个搜索字段(它可以工作)但是其中一个搜索条件拒绝填充变量,每次我点击“搜索”它会为我提供一个特定值的弹出窗口原因。我没有找到任何使该列在代码中的任何位置都不同的东西。我知道搜索代码很难看,但它适用于所有其他领域。问题是“Avtalsnr”由于某些原因它只是讨厌我:(。我尝试将标准移到最后和中间但仍然相同。当我删除对[Avtalsnr]的引用时它没有要求它。任何想法在这可能是什么?
按“搜索”时执行的代码:
Private Sub subFindTruck()
On Error GoTo subFindTruck_Err
DoCmd.ApplyFilter "", "[Avtalsnr] Like ""*"" & Forms![Ändra Truckar]!txtFindTruck & ""*"" Or [Ansvarig Gruppchef] Like ""*"" & Forms![Ändra Truckar]!txtFindTruck & ""*"" Or [K-ställe] Like ""*"" & Forms![Ändra Truckar]!txtFindTruck & ""*"" Or [Modell] Like ""*"" & Forms![Ändra Truckar]!txtFindTruck & ""*"" Or [Trucktyp] Like ""*"" & Forms![Ändra Truckar]!txtFindTruck & ""*"" Or [Maskinnummer] Like ""*"" & Forms![Ändra Truckar]!txtFindTruck & ""*"" Or [Leverantör/Ägare] Like ""*"" & Forms![Ändra Truckar]!txtFindTruck & ""*"" Or [Avtalstyp] Like ""*"" & Forms![Ändra Truckar]!txtFindTruck & ""*""", ""
subFindTruck_Exit:
Exit Sub
subFindTruck_Err:
MsgBox Error$
Resume subFindTruck_Exit
End Sub
以下是表单基于的SQL查询:
SELECT TruckList.TruckID, TruckList.InternalNumber AS Internnummer, TruckList.LeaseNumber AS Avatalsnr, Owner.OwnerName AS [Leverantör/Ägare], Users.UserName AS [Ansvarig Gruppchef], WareHouseUnit.UnitNumber AS [K-ställe], TruckModel.TruckModelName AS Trucktyp, TruckModel.TruckModel AS Modell, TruckList.MachineNumber AS Maskinnummer, LeaseType.LeaseTypeName AS Avtalstyp, TruckList.LeaseStart AS Avtalsstart, TruckList.LeaseEnd AS Avtalsslut, TruckList.LeaseLenght AS [Avtalslängd (m)], TruckList.UsageHours AS Drifttid, TruckList.Cost AS Kostnad, TruckLocation.LocationName AS [Truckens placering], TruckList.Active AS Aktiv, TruckList.LeaseInBinder AS [Avtal i Pärm], TruckList.ServiceContract AS [Service Kontrakt], TruckList.SGanalysis AS [SG analys]
FROM LeaseType INNER JOIN (Users INNER JOIN (TruckModel INNER JOIN (WareHouseUnit INNER JOIN ((TruckList INNER JOIN Owner ON TruckList.[OwnerID] = Owner.[OwnerID]) INNER JOIN TruckLocation ON TruckList.LocationID = TruckLocation.LocationID) ON WareHouseUnit.UnitID = TruckList.UnitID) ON TruckModel.TruckModelID = TruckList.TruckModelID) ON Users.UserID = WareHouseUnit.UserID) ON LeaseType.LeaseTypeID = TruckList.LeaseTypeID;