Archived

This topic is now archived and is closed to further replies.

Crispy

VB

Recommended Posts

Hi, Why does this: NewData As String NewData = "data" strSQL = "Insert into TTable (TField) Values (" & conQuote & NewData & conQuote & ")" produce this: "Insert into TTable (TField) Values (data)" not this: "Insert into TTable (TField) Values (''data'')" , which is the correct one. Thanks, Crispy

Share this post


Link to post
Share on other sites
Why don''t you just type:

strSQL = "Insert into TTable (TField) Values (''" & NewData & "'')"

?

It gets ''funny'' to look at when you have more than one field but it works.

One way I''ve done it for one of my systems was this:



  
DB_SQL = "select * from Collection where serialnumber = ''" & SerialNumber & "''"
Set DB_RetrieveSN_DB = DB_database.OpenRecordset(DB_SQL) ''Open SQL Statement 1

If DB_RetrieveSN_DB.EOF Then ''check to see if serial number is not in database
DB_database.Execute _
"insert into Collection(serialnumber, date_load) values(''" _
& SerialNumber & "'',''" & CollectionDate.Text & "'')"
Else
DB_database.Execute _
"update Collection set date_load = " & CollectionDate.Text & _
" where serialnumber = ''" & SerialNumber & "''"
End If

Share this post


Link to post
Share on other sites
It took me a while to admire your profound solution. Brrr... It''s just that I''m a VB n00b and I''m not at all comfortable with the concept yet - especially the ampersands.

Thanks a bunch, anyway - helped me out there!

PS - Access sample code uses the conQuote solution - it seems to be working for them.

Crispy

Share this post


Link to post
Share on other sites