Update records

AndyShuter

Registered User.
Local time
Today, 21:12
Joined
Mar 3, 2003
Messages
151
Erm, I know this sound a bit silly....but I woudered if there was a way of adding anew record to a table using vb code?

My table is called tblTransmissions

The fields are
TransmissionCode, AutoNumber
TransmissionDate, Date/Time
TransmissionTime, Date/Time
TransmissionStatus / Text
TransactionCode / Number (Linked to another table by One-To-Many)

When I hit a command button, I would like to update the recordset by firstly adding a new record. Then set Date & Time to Now, Then TransmissionStatus to a control on a form, same with the Transaction Code.

Normally I would place the values on a form and update the values that way, but just wondered if this was possible!

Thanks
 
Of course. You can either execute an append query in code (CurrentDb.Execute) or open a DAO or ADO recordset and add the record that way.
 
Pbaldy:

Why do people recommend using DAO/ADO for appending data rather than DoCmd.RunSQL "INSERT INTO...."?

I understand the use of DAO/ADO for cycling through records, but I'm not sure why it's better than using an SQL command.

Thanks.

SHADOW
 
Shadow: I don't know why. I simply included it as one of the alternatives. Executing SQL should be more efficient. By the way, CurrentDb.Execute is more efficient that DoCmd.RunSQL.
 
Paul:

Executing SQL should be more efficient. By the way, CurrentDb.Execute is more efficient that DoCmd.RunSQL.

I didn't know that CurrentDb.Execute can run a SQL statement. I've always used DoCmd.RunSQL. If you say that it's more efficient, then I'll change my ways :)

Thanks

SHADOW
 

Users who are viewing this thread

Back
Top Bottom