SQL INSERT INTO Syntax

  • Thread starter Thread starter byman2030
  • Start date Start date
B

byman2030

Hello, with Access2000 I am trying to use SQL to update a table called
ReminderNotes.

INSERT INTO ReminderNotes (ReminderDate)
VALUES (*);

I would like the * to point to the variable txtdatefield1.text (located in
UserUpdateForm an open form), and for the query to not prompt the user.

I have tried various path configurations but haven't found the correct
syntax as yet.

In fact, I am wondering if I must first set a global variable for the
datefield so the query can see it.

By the way, if there is an easier to do this (pass date value from open form
textbox to another table) without SQL I'd also be glad to hear about it.

Thanks for the help

byman2030
 
You can build a sql string using a reference to any variable or form control.
Try something like this:

Dim strSQL as String
strSQL = "INSERT INTO ReminderNotes (ReminderDate) VALUES (#" &
Me.txtDateField1 & "#)"
DoCmd.RunSql strSQL

If you want to do an insert against a table other than the one your form is
bound to, there are a couple of ways. This one works, as does using ADO or
DAO to execute sql.

HTH,
Barry
 
Thanks Barry!
You can build a sql string using a reference to any variable or form control.
Try something like this:

Dim strSQL as String
strSQL = "INSERT INTO ReminderNotes (ReminderDate) VALUES (#" &
Me.txtDateField1 & "#)"
DoCmd.RunSql strSQL

If you want to do an insert against a table other than the one your form is
bound to, there are a couple of ways. This one works, as does using ADO or
DAO to execute sql.

HTH,
Barry
 
Back
Top