[AccessD] FW: CodeL

Eric Starkenburg eric.starkenburg at home.nl
Sat Mar 8 03:15:04 CST 2008


Cool:)

I never went that far figuring out how I could make it work but this works
like a charme!

The 'trouble' you kinda have to go through to handle quotes left me with
using recordsets a long time ago since there's no need for conversions etc.
leaving the code more 'core' with less handling keeping it more simple.
...ohwell I am glad you pointed this out and I'm sure others are too:)

Thnx,
Eric

-----Original Message-----
From: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Arthur Fuller
Sent: Saturday, March 08, 2008 12:41 AM
To: Access Developers discussion and problem solving
Subject: Re: [AccessD] FW: CodeL

I guess I didn't explain myself well. Sorry, Eric. Following your lead, I
created an unbound form and a textbox control on it called txtText. I added
a button to save, whose code follows (in addition to a simple function
called qq(), to save you the hassle of wrapping the string as you did in
your code).

I pasted your Dutch string into the textbox on the form, then clicked the
Save button. Step through my code and you will see that it performs exactly
as advertised, and successfully saves the row to the table.

<code>
Private Sub Save_btn_Enter()
    Dim db As DAO.Database
    Set db = CurrentDb
    Dim strtest As String
    'txtTest = qq(dit moe'st ook "maar" eens getest wor'dn)
    With Me
        strtest = Replace(.txtText, Chr(39), Chr(39) & Chr(39))
        strtest = Replace(.txtText, Chr(34), Chr(34) & Chr(34))
        Debug.Print strtest
    End With
    'your code was:
    'db.Execute "insert into TestText (TestText) VALUES ('" & strtest & "')"
    Dim s As String
    s = "insert into TestText (TestText) VALUES (" & qq(strtest) & ")"
    Debug.Print s
    db.Execute s
    Set db = Nothing
End Sub


Function qq(s As String) As String      'this should go in a public module.
I just put it here for simplicity
    qq = Chr(34) & s & Chr(34)
End Function

</code>

hth,
Arthur

On 3/7/08, Eric Starkenburg <eric.starkenburg at home.nl> wrote:
>
> Arthur,
>
> I just used the code underneith to test your theory....
>
> The table used has just one field called test in table test.
> The form is called form1 and the textbox is called txtTest
> Sample text in textbox on a form: dit moe'st ook "maar" eens getest wor'dn
>
> Code used to save to table on a buttonpress:
> Dim db As DAO.Database
> Set db = CurrentDb
> Dim strtest As String
>
> strtest = Replace(txtTest, Chr(39), Chr(39) & Chr(39))
> strtest = Replace(txtTest, Chr(34), Chr(34) & Chr(34))
>
> db.Execute "insert into test (test) VALUES ('" & strtest & "')"
> Set db = Nothing
>
> Works like a charme without quotes in a sentence but with the sample text
> I
> get an error: Operator missing blablabla
>
> What did I do wrong?
>
>
--
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com




  _____  

avast! Antivirus <http://www.avast.com> : Uitgaande bericht is niet besmet. 


Virus Gegevensbestand (VPS): 080307-0, 07-03-2008
Getest op: 8-3-2008 10:15:04
avast! - auteursrecht (c) 1988-2008 ALWIL Software.






More information about the AccessD mailing list