我想更新文本框使用dlookup當用戶選擇組合框中的項目時,我不能在文本框的控件源中執行dlookup,因爲我需要將它存儲在表中,所以我正在默認值。在文本框中使用dlookup
下面是使用DLookup,但它不工作:
=DLookUp([Ground Clearance_inches],"tbVehicles","[Vehicle]=[Forms]![Cover Data]![vehicle]")
注意地面Clearance_inches在tbVehicles表號的數據類型。
我想更新文本框使用dlookup當用戶選擇組合框中的項目時,我不能在文本框的控件源中執行dlookup,因爲我需要將它存儲在表中,所以我正在默認值。在文本框中使用dlookup
下面是使用DLookup,但它不工作:
=DLookUp([Ground Clearance_inches],"tbVehicles","[Vehicle]=[Forms]![Cover Data]![vehicle]")
注意地面Clearance_inches在tbVehicles表號的數據類型。
這應該是
Private Sub vehicle_AfterUpdate()
''Vehicle is a number
Me.MyTextBoxNameHere = _
DLookUp("[Ground Clearance_inches]","tbVehicles","[Vehicle]= " _
& [Forms]![Cover Data]![vehicle])
''Vehicle is text
Me.MyTextBoxNameHere = _
DLookUp("[Ground Clearance_inches]","tbVehicles","[Vehicle]= '" _
& Replace([Forms]![Cover Data]![vehicle], "'","''") & "'")
''If the current form is [Cover Data] then
Me.MyTextBoxNameHere = _
DLookUp("[Ground Clearance_inches]","tbVehicles","[Vehicle]= '" _
& Replace(Me.[vehicle], "'","''") & "'")
End Sub
我不確定它是在默認值中,但在VBA中where子句將是「[Vehicle] =」& [Forms]![Cover Data]![車輛] 爲什麼不把它放在組合框的OnUpdate事件?
這算什麼,我需要做的,但它給了錯誤:私人小組vehicle_AfterUpdate() =使用DLookup([地面Clearance_inches], 「tbVehicles」, 「[汽車] =」 & [Forms]![Cover Data]![vehicle]) End Sub – nman84 2012-03-06 20:05:02