Stuart McLachlan
stuart at lexacorp.com.pg
Mon Jun 28 19:19:29 CDT 2004
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.