Re: Write to table
- From: "Allen Browne" <AllenBrowne@xxxxxxxxxxxxxx>
- Date: Thu, 11 May 2006 00:49:36 +0800
Yes, you can use either method to insert records.
Using unbound forms involves extra work though, loading existing records,
keeping track of whether this is an existing record (so you need to execute
an UPDATE) or a new record (so you need to execute an INSERT), and making
sure you don't do it multiple times as an impatient user clicks repeatedly.
--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.
"Zoltar54" <Zoltar54@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:EEA1F98C-487D-4CDE-B00B-6CB8963F1471@xxxxxxxxxxxxxxxx
Allen,
Would example A work for me if I wanted to enter data from an unbound
textbox on a form to a record table?
Z
"Allen Browne" wrote:
Couple of options:
a) Execute an Append query statement.
b) OpenRecordset, and add the record.
Example of (a):
===========
Dim strSql As String
strSql = "INSERT INTO Table1 (Field1, Field2, Field3), " & _
"6 AS F1, 'Springfield' AS F2, #1/1/2006# AS F3"
dbEngine(0)(0).Execute strSql, dbFailOnError
To get the SQL statement right, you can mock up a query typing any values
in. Then change it to an Append query (Append on Query menu), and switch
to
SQL view (View menu) to see the example.
Example of (b):
===========
Dim rs As DAO.Recordset
Set rs = dbEngine(0)(0).OpenRecordset("Table1")
rs.AddNew
rs!Field1 = 6
rs!Field2 = "Springfield"
rs!Field3 = #1/1/2006#
rs.Update
rs.Close
Set rs = Nothing
--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.
"Vsn" <vsn at hotmail> wrote in message
news:uvMPin%23cGHA.1456@xxxxxxxxxxxxxxxxxxxxxxx
Can some one tell me if its possible to add data to a table, in a bit
of a
sameway data can be retrived by aggregate functions? And if this is
possible what the code would be to use it from VBA.
.
- Follow-Ups:
- Re: Write to table
- From: Zoltar54
- Re: Write to table
- References:
- Write to table
- From: Vsn
- Re: Write to table
- From: Allen Browne
- Write to table
- Prev by Date: Re: Making use of a Passed Argument
- Next by Date: Re: Text Box to show last name only
- Previous by thread: Re: Write to table
- Next by thread: Re: Write to table
- Index(es):
Relevant Pages
|