Replacing characters

  • Thread starter Thread starter reidarT
  • Start date Start date
R

reidarT

I use this method to change a field
Dim Kilde As String
Kilde = Chr(10)

Set db4 = DBEngine.Workspaces(0).Databases(0)
Set qd4 = db4.CreateQueryDef("", "UPDATE tblTest SET
tblTest.Comments = Replace(TekstFelt),Kilde,'<br>')")
qd4.Execute
The problem is that Chr(10) is supposed to be the Enter betwwen lines in a
memo-field,
but it doesn't work.
Do I use the wrong Ascii character?
reidarT
 
here is some code you can run to find out which ASCII codes are being used

'~~~~~~~~~~~~~~~

Sub WhatIsAscii()

'strive4peace

'NEEDS REFERENCE TO:
'Microsoft DAO Object Library

'substitute your table name for --> Tablename
'substitute your field name for --> Fieldname

On Error GoTo Proc_Err

Dim r As DAO.Recordset

Dim i As Integer

Set r = CurrentDb.OpenRecordset("Tablename", dbOpenSnapshot)

If r.EOF Then
MsgBox "No records in this table", , "Cannot continue"
GoTo Proc_Exit
End If

Do While Not r.EOF

If Len(Nz(r!Fieldname, "")) = 0 Then GoTo NextRecord

For i = 1 To Len(r!Fieldname)

Select Case MsgBox( _
r!Fieldname & vbCrLf & vbCrLf _
& " --> " & i & " --> " _
& Mid(r!Fieldname, i, 1) & " --> " _
& Asc(Mid(r!Fieldname, i, 1)) _
& vbCrLf & vbCrLf _
& "Yes to Continue," _
& " No to continue after current record," _
& " Cancel to Stop" _
, vbYesNoCancel, "character position --> character --> ASCII")

Case vbCancel: GoTo Proc_Exit
Case vbNo: GoTo NextRecord
End Select

Next i
NextRecord:
r.MoveNext
Loop

MsgBox "Done", , "Done"

Proc_Exit:
On Error Resume Next
'close and release object variables
r.Close
Set r = Nothing
Exit Sub

Proc_Err:
MsgBox Err.Description, , _
"ERROR " & Err.Number & " WhatIsAscii"
'press F8 to step through code and debug
'remove next line after debugged
Stop: Resume
End Sub
'~~~~~~~~~~~~~~~

Warm Regards,
Crystal
*
(: have an awesome day :)
*
MVP Access
Remote Programming and Training
strive4peace2006 at yahoo.com
*
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top