Hi there, I've using the ADO connection within vb6. I know about the Data.Recordset.Addnew
and Data.Update way of adding a new record but is there a way of adding a new record without having to link objects to the Table/Entity? Is it possible to use variables to do this. Currently i have TxtBatch which i would like to assign to DBbatch and add the value of that record to the database. Database = MS Access 2000. Cheers

5 Years
Discussion Span
Last Post by gowans07

you can use an SQL INSERT statement eg

"INSERT INTO mytable (newname, newamount) VALUES('Fred',25);"


Quick response as always. Thanks. Below is the code i have created, when ran i get data type conversion error. I havent declared any of the variables, i have a feeling it could be because of DBBDate? Any ideas Up-Voted

DBOrderNumber = "3"
        DBCustomerID = "CODLAD"
        DBBDate = "01012011"
        Data6.Recordset.OpenRecordset "INSERT INTO Tbl_Order (Order_Number,Customer_ID,Date_Received).Value(DBOrderNumber,DBCustomerID,DBBDate)"

if date_received column typed as a Date/Time, then I am not sure whether that is a valid format. There should be a space instead of a . before Value which should be VALUES, also you need to construct the string, you cannot pass in the variables because they are out of scope for the database engine.
the last part of the string, from the first ")" should be something like

) VALUES(" & OrderNumber & ", " & CustomerId & ", #" & DBBDate & "#);"


Okay thank you very much, i think i have corrected the conversion error. I needed to declare what DBBDate was. Thanks again. Up-Voted

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.