473,322 Members | 1,421 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

How can I Insert into a table with data from a form

Hi,
Right now I have a form with a couple of fields. Let say: Name and
Date. Now I want to create an append query to insert these data into a
table with the field of Name and Date. I am not very familiar with
append query. Anybody know what is the sql statement that can do this?
Any help would be appreciated.

Thanks
Khoa

Apr 28 '06 #1
5 1338
If you use the query wizard

1) new query
2) from menu line select Apend query and it will as you what table and
you select the table mentioned above.
3) In one of the columns go to 'append to' and select Name
4) go to the top line for that same column and right click and chose
build
then forms
then all forms
pick the form that has the name filed
pick the name field
pick value on far right and double click
5 Repeat steps 3 and 4 for the date.
close the query and name it what you want. (example AppendNameQuery

Now back on the form, select the event (button click or whatever you
want to use to trigger this append.
write the code
docmd.setwarnings false set the warnings off
docmd.openquery "AppendNameQuery"
docmd.setwarnings true reset to give warnings if you
turned them off

Apr 28 '06 #2
Is there a reason you don't want to bind the form to the table by
setting the Recordsource property?

Apr 28 '06 #3
if u want to use VBA use this

dim rs as recordset
dim db as database
set db = currentdb

set rs=db.openrecordset("select * from table '"+<tablename>+"')
with rs
..addnew
![date]=txtdate
![name]=txtname
..update
end with
or u can use

db.execute("insert into table <tablename> set name ='"+txtname'");

'u may want to do some modifications ....the code may not exactly
correct....

Apr 30 '06 #4
Thank you: Ron2005, pietlin...@hotmail.com, roade...@gmail.com for all
the help. I was able to create an append query and to insert new row
into the table. However, the query does not insert one row but as many
row as I have in the table before. For example, if I have 5 rows in the
original table, it will insert 5 duplicate rows (This was possible
because i have an autonumber field). Does anybody know how to limit it
to insert only 1 row?

Thanks in advance.

May 1 '06 #5
Just an update to my problem. I found out that the only reason it
create problem when I tried to append was because i use a field from
another table. Once I got rid of the link/connection I was able to add
1 row only. Thanks

May 1 '06 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: newbie_mw | last post by:
Hi, I need urgent help with a novice problem. I would appreciate any advice, suggestions... Thanks a lot in advance! Here it is: I created a sign-up sheet (reg.html) where people fill in their...
8
by: Sans Spam | last post by:
Greetings! I have a table that contains all of the function permissions within a given application. These functions are different sections of a site and each has its own permissions (READ, WRITE,...
0
by: Suler Abou | last post by:
Hi, I'm having a problem with an SQL statement, I have a statement that goes like this: "INSERT INTO table VALUES('TransID','CID',etc...);" it basically adds new data to a table. When the...
1
by: Abareblue | last post by:
I have no clue on how to insert a record into access. here is the whole thing using System; using System.Drawing; using System.Collections; using System.ComponentModel;
12
by: shank | last post by:
I'm trying to use online samples for submitting multiple records from ASP into a stored procedure. Failing! Through the below form, a user could be submitting many records at a time. I'm not...
2
by: Geoffrey KRETZ | last post by:
Hello, I'm wondering if the following behaviour is the correct one for PostGreSQL (7.4 on UNIX). I've a table temp_tab with 5 fields (f1,f2,f3,...),and I'm a launching the following request :...
1
by: solomon_13000 | last post by:
connection.asp: <% Sub RunQueryString (pSQL,parms) on error resume next Set conn = Server.CreateObject("ADODB.Connection") conn.open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" &...
4
by: =?Utf-8?B?UmljaA==?= | last post by:
On a form - I have a datagridview which is docked to the entire form. The datagridview allows users to Delete and/or Add Rows. On the Form_Load event I Fill the datagridview source table with a...
0
BenRatcliffe
by: BenRatcliffe | last post by:
Hi there, I was wondering if anyone could help me. I have a comlpex database with a number of forms that have data entered on them and then saved into the correct table etc. In this instance I am...
58
by: bonneylake | last post by:
Hey Everyone, Well recently i been inserting multiple fields for a section in my form called "serial". Well now i am trying to insert multiple fields for the not only the serial section but also...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.