SQL INSERT INTO Syntax

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
 
G

Guest

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
 
B

byman2030

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Example Of VBA SQL Statement 0
SQL "insert into" syntax 4
Set Querydef SQL to Null (Open an empty query editor) 20
Please Help with syntax 6
SQL Error 2
SQL syntax problem 3
SQL syntax for INSERT 5
Update SQL 10

Top