VB

Started by
1 comment, last by Crispy 21 years, 9 months ago
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
"Literally, it means that Bob is everything you can think of, but not dead; i.e., Bob is a purple-spotted, yellow-striped bumblebee/dragon/pterodactyl hybrid with a voracious addiction to Twix candy bars, but not dead."- kSquared
Advertisement
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  
- Advice, eh? Well, besides working on your swing...you know, besides that...I'd have to think.
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
"Literally, it means that Bob is everything you can think of, but not dead; i.e., Bob is a purple-spotted, yellow-striped bumblebee/dragon/pterodactyl hybrid with a voracious addiction to Twix candy bars, but not dead."- kSquared

This topic is closed to new replies.

Advertisement