您的數據的工作一個新的數據庫包含換行符和組合框只顯示每個記錄一行。
要顯示的數據可以代替換行的行源。
SELECT Replace([CustomerName],vbCrLf, " ") as CName FROM table
' vbCrLf is the VBA constant for linebreaks (Cr - Carrige Return, Lf - LineFeed)
這是很差的數據庫規範化(想象一下,您想搜索一個與城市相同的客戶名稱,例如巴黎)。每行應該是表中的一個單獨的字段(並且也是郵政編碼)。如果每個數據都有一個換行符(例如沒有街道 - >空行),則可以將數據分割到新的字段中。
'Put this code in a module
'Split function
Public function splitCustomerName(ByVal strCustomerName as String, ByVal index as long) as String
Dim arrCustomerName As Variant ' or declare a fixed array if you know the number of lines
arrCustomerName = Split(strCustomername,vbCrLf)
splitCustomerName = arrCustomerName(index)
End Function
查詢
UPDATE table SET newCustomerName = splitCustomerName([table].[CustomerName],0)
, newCustomerStreet = splitCustomerName([table].[CustomerName],1)
, newCustomerCity = splitCustomerName([table].[CustomerName],2);
剛剛創建的名稱,街道,城市所需的列,然後運行查詢。 如果您刪除CostumerName列並重命名該表(例如newTable),則可以使用該表的舊名創建查詢,該查詢的行爲與舊錶類似。
SELECT *
, newCustomerName & vbCrLf & newCustomerStreet & vbCrLf & newCustomerCity as CustomerName
FROM newTable
您檢查了換行符(增加表的數據表視圖中行的高度)? – BitAccesser
啊,非常感謝。這就是它!如果有方法可以標記答案,請讓我知道 – Istaley