我想用特殊格式保存一些数据。例如:
我可以在Access中保存这些信息,但是当我想向用户显示这些信息时。它在文本框中显示如下: 的 AAAABBBBCCCCDDDD Whitout任何换行。 我的问题是:如何在MS Access DB中保存换行符?
非常感谢你的帮助!
编辑1
即我在.txt文件中有这个信息块:
KENNLINIE KLPRAIL 3
LANGNAME "Kennlinie zur Umsetzung Raildrucksensorspannung in Raildruck"
FUNKTION GGDSKV
EINHEIT_X "V"
EINHEIT_W "MPa"
ST/X 0.4980468750000000 1.8002319335937500 5.0000000000000000
WERT 0.0000000000000000 4.5000000000000000 15.5600000000000000
END
我想将 KLPRAIL 3 保存在一列中
EINHEIT_X "V"
EINHEIT_W "MPa"
ST/X 0.4980468750000000 1.8002319335937500 5.0000000000000000
WERT 0.0000000000000000 4.5000000000000000 15.5600000000000000
在另一栏
我可以使用这段代码完成这项工作:
Dim kennL As String
Dim kennLS As Boolean
Dim kennLvalue As String
Dim kennLwert As String
Dim keLx As String
Dim keLw As String
Dim kelwer As String
kennL = InStr(1, entireline, "KENNLINIE")
keLx = InStr(1, entireline, "EINHEIT_X")
keLw = InStr(1, entireline, "EINHEIT_W")
keLsx = InStr(1, entireline, "ST/X")
kelwer = InStr(1, entireline, "WERT")
keLend = InStr(1, entireline, "END")
If kennL = 1 Then
kennLvalue = Mid(entireline, 10)
kennLS = True
End If
If keLx = 4 And kennLS = True Then
kennLwert = kennLwert + Mid(entireline, 4) + vbNewLine
End If
If keLw = 4 And kennLS = True Then
kennLwert = kennLwert + Mid(entireline, 4) + vbNewLine
End If
If kennLS = True And (keLsx = 4 Or kelwer = 4) Then
kennLwert = kennLwert + Mid(entireline, 4) + vbNewLine
End If
If kennLS = True And keLend = 1 Then
DoCmd.RunSQL ("INSERT INTO Test_dcml (WertName,WertValue) VALUES ('" & kennLvalue & "','" & kennLwert & "');")
kennLS = False
End If
但如果我向用户显示此信息。这些信息如下所示:
EINHEIT_X "V" EINHEIT_W "MPa" ST/X 0.4980468750000000 1.8002319335937500 5.0000000000000000 WERT 0.0000000000000000 4.5000000000000000 15.5600000000000000
EDIT2
I use this code to show this Information to user:
Dim rcst As Recordset
Set rcst = CurrentDb.OpenRecordset("Test_Wertquery")
rcst.MoveFirst
Text5.SetFocus
Me.Text5.Text = rcst.Fields("WertValue").Value
答案 0 :(得分:1)
由于您存储的文本值在MsgBox
中正确显示,这意味着换行符会正确存储在您的表格中。所以问题在于文本框。
选中复选框属性表的“数据”选项卡上的“文本格式”属性。
如果尚未设置,则将其更改为“纯文本”。以“Rich Text”作为格式,系统内容中的换行符将被忽略。
答案 1 :(得分:0)
我会这样做:
Dim rcst As DAO.Recordset
Set rcst = CurrentDb.OpenRecordset("Test_Wertquery")
If Not rcst.EOF Then
rcst.MoveFirst
Me.Text9 = rcst.Fields("WertValue").Value
rcst.Close
End If
Set rcst = Nothing