[AccessD] Troubles with insert

Oleg_123 at xuppa.com Oleg_123 at xuppa.com
Mon Jun 28 20:59:15 CDT 2004


Hi Stuart,

thanks a lot, by "work" i meant thats insirting something, i didn't know
where exactly to place qoutes and comes. I'll try it tomorrow morning,
hope it works..

> On 28 Jun 2004 at 19:06, Oleg_123 at xuppa.com wrote:
>
>> i can't remember what am i doing wrong; when i try
>> strSQL = "Insert into Testing(EntID,AttribID, AttribName,
>> DataTypeCode,Comment) Values( 'txtEntID.Text','txtAttribID.Text','
>> txtAttribName.Text',' txtDataTypeCode.text',' txtComment.Text')"
>>
>> it works, and this way doesn't..
>>
>
> It might "work" , but you won't get what you want in the table Testing.
> You  will get the literal strings "txtEntID.Text" etc in the added
> record rather  than the value of those controls
>
>> Private Sub cmdImport_Click()
>>
>> Dim strSQL As String
>>
>> strSQL = "Insert into Testing(EntID,AttribID, AttribName,
>> DataTypeCode,Comment) Values( txtEntID.Text,txtAttribID.Text,
>> txtAttribName.Text,txtDataTypeCode.text,txtComment.Text)"
>>
> You need quotes round the numeric values for the numeric fields and
> quotes  around the text data so every Value here will generate an error
>
>>
>> Private Sub cmdImport_Click()
>> Dim a, b, c, d, e, f
>> a = txtAppsId
>> b = txtEntID
>> c = txtAttribID
>> d = txtAttribName
>> e = txtDataTypeCode
>> f = txtComment
>>
>> Dim strSQL As String
>>
>> strSQL = "Insert into Testing(AppsID, EntID,AttribID, AttribName,
>> DataTypeCode,Comment) Values( a,b,c, & """ & d & """ & , & """ & e &
>> """ &, & """ &  f & """ &)"
>>
>
> Try a "MsgBox strSQL" and you will see exactly what you are inserting.
>
> Soution:
> You need to build strSQL properly with boilerplate text and the values
> you  need.  Note the quotes around each piece of boilerplate including
> the first  block up to the start of the first variable.
>
> strSLQ = "Insert into Testing(AppsID, EntID,AttribID, AttribName,
> DataTypeCode,Comment) Values( " _
>    & a & "," & b & "," & c & ",'" & d & "','" & e & "','" & f & "')"
>
>
>
> --
> Lexacorp Ltd
> http://www.lexacorp.com.pg
> Information Technology Consultancy, Software Development,System Support.
>
>
>
> --
> _______________________________________________
> AccessD mailing list
> AccessD at databaseadvisors.com
> http://databaseadvisors.com/mailman/listinfo/accessd
> Website: http://www.databaseadvisors.com



-----------------------------------------
Make Money and Find Love at Finally.com
http://www.finally.com/?link=webmail





More information about the AccessD mailing list