VilaRestal
';drop database master;--
- Local time
- Today, 04:39
- Joined
- Jun 8, 2011
- Messages
- 1,046
and if we want to INSERT a new record to the table from the form, how can we do it?
That's a quite different issue.
It depends on what you mean.
Normally you would let access handle new records by binding a form to a table or query (its recordsource property) and going to a new record and filling it in.
You can however execute SQL Insert statements with the CurrentDb.Execute method:
Code:
Dim strSQL As String
Dim iSID As Integer, iCID As Integer
Dim strCRS As String
iSID = 777
iCID = 1
strCRS = "Test"
strSQL = "insert into Enrollment (cid, sid, crsname) values (" & iSID & "," & iCID & ",'" & strCRS & "')"
Debug.Print "strSQL = """ & strSQL & """"
CurrentDb.Execute strSQL
You can elso execute UPDATE and DELETE SQL commands.
But generally use the tools Access gives you for creating, modifying and deleting records. To start out with Access executing SQL left right and centre is a strange way to start. Most people would regard that as quite an advanced thing to be doing

By the way, Access's own SQL has some limitations and peculiarities and I'm not very familiar with what it can and can't do that Transact SQL can. I tend to work with T-SQL these days.