473,624 Members | 2,561 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Update a Table

I have a very simple database. I have information in a form that I would
like to write to a table using some code. The table is called tblTest. The
field I would like to write to is called Date. The data which I would like
to write is Date(). Please can someone help me with this simple code?

Many Thanks,
John
Nov 12 '05 #1
4 2393
news.btinternet .com wrote:
I have a very simple database. I have information in a form that I would
like to write to a table using some code. The table is called tblTest. The
field I would like to write to is called Date. The data which I would like
to write is Date(). Please can someone help me with this simple code?


Date is a reserved word in Access and it isn't very descriptive - I'd recommend
changing it to prevent problems but if you bracketed the field name you might
be successful with:

CurrentDb.Execu te "INSERT INTO tblTest ([Date]) VALUES ( Date() )";

Of course you didn't give us enough info to say definitively. Is the form
bound to the tblTest table? Are you created a new record or updating an
existing? And you'll need more data for the record in tblTest such as a primary
key value.

Generally you bind your forms to a table or query by setting the form's
RecordSource property to that data source. Then you can bind controls to
fields in that datasource. Then modifying the value of the control updates
the bound field in the bound table/query.

--
'-------------------------------
' John Mishefske
'-------------------------------

Nov 12 '05 #2
"news.btinterne t.com" <te*****@btinte rnet.com> wrote in message
news:bu******** **@sparta.btint ernet.com...
I have a very simple database. I have information in a form that I would
like to write to a table using some code. The table is called tblTest. The
field I would like to write to is called Date. The data which I would like
to write is Date(). Please can someone help me with this simple code?

Many Thanks,
John

Normally, there would be no point writing code for this sort of thing. If
your form is bound to the table, then you can simply edit the data using the
form and if you needed, for example, today's date automatically entered in a
record then you could use the Date() function as the default value.

If you are certain you need (or want) to write code, then the first thing to
consider is where to write it - that is, when should your code run. You
might want it to run when the form first opens or when a new record is
started or when the user presses a button. Basically, if your form is bound
to a table then you could simply write:

Me!AnyDate = Date()

Where AnyDate is the name of the field. I would not use reserved words
(Date, Name, etc) for field names.
If your form is not bound, or you wanted to update a record other than the
current one then we would need to know which is the primary key so we know
which row to update. In other words give further details about the
structure of tblTest.
Fletcher

Nov 12 '05 #3
I am sorry for the lack of information. The form is bound to the table
tblTest. I have 3 fields within that table which are testid, testname and
testdate. testid is the primary key. The name field will be filled in
through the form. However I have a button on the form, which when clicked I
would like the field testdate to be updated with the current date. That is
why I was asking for the code. When this button is clicked a report is
generated the field is data stamped.

Thanks,

John
"Fletcher Arnold" <fl****@home.co m> wrote in message
news:bu******** **@sparta.btint ernet.com...
"news.btinterne t.com" <te*****@btinte rnet.com> wrote in message
news:bu******** **@sparta.btint ernet.com...
I have a very simple database. I have information in a form that I would
like to write to a table using some code. The table is called tblTest. The field I would like to write to is called Date. The data which I would like to write is Date(). Please can someone help me with this simple code?

Many Thanks,
John

Normally, there would be no point writing code for this sort of thing. If
your form is bound to the table, then you can simply edit the data using

the form and if you needed, for example, today's date automatically entered in a record then you could use the Date() function as the default value.

If you are certain you need (or want) to write code, then the first thing to consider is where to write it - that is, when should your code run. You
might want it to run when the form first opens or when a new record is
started or when the user presses a button. Basically, if your form is bound to a table then you could simply write:

Me!AnyDate = Date()

Where AnyDate is the name of the field. I would not use reserved words
(Date, Name, etc) for field names.
If your form is not bound, or you wanted to update a record other than the
current one then we would need to know which is the primary key so we know
which row to update. In other words give further details about the
structure of tblTest.
Fletcher


Nov 12 '05 #4
"news.btinterne t.com" <te*****@btinte rnet.com> wrote in message
news:bv******** **@sparta.btint ernet.com...
I am sorry for the lack of information. The form is bound to the table
tblTest. I have 3 fields within that table which are testid, testname and
testdate. testid is the primary key. The name field will be filled in
through the form. However I have a button on the form, which when clicked I would like the field testdate to be updated with the current date. That is
why I was asking for the code. When this button is clicked a report is
generated the field is data stamped.

Thanks,

John
Then, if AnyDate is the name of the field, all you have to write is:

Me!AnyDate = Date()

But are you sure the user should have to click a button? If you made the
default value for that field the current date, then today's date would be
automatically put in without anyone having to click anything.

I didn't quite get the report bit here: When this button is clicked a report is generated the field is data

stamped.
Fletcher
Nov 12 '05 #5

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

Similar topics

7
248455
by: Dave | last post by:
I have 2 tables, one with names, and another with addresses, joined by their CIVICID number (unique to the ADDRESSINFO table) in Oracle. I need to update a field in the NAMEINFO table for a particular surname in a particular town. I can select the records fine with this syntax (testing in Oracle SQL* Plus) SELECT NAMEINFO.LASTNAME, NAMEINFO.FIRSTNAME, NAMEINFO.MIDDLENAME, NAMEINFO.GENDER, ADDRESSINFO.REGION FROM NAMEINFO, ADDRESSINFO...
8
89304
by: Lauren Quantrell | last post by:
In VBA, I constructed the following to update all records in tblmyTable with each records in tblmyTableTEMP having the same UniqueID: UPDATE tblMyTable RIGHT JOIN tblMyTableTEMP ON tblMyTable.UniqueID = tblMyTableTEMP.UniqueID SET tblMyTable.myField = tblMyTableTEMP.myField, tblMyTable.myField2 = tblMyTableTEMP.myField2,
17
5004
by: kalamos | last post by:
This statement fails update ded_temp a set a.balance = (select sum(b.ln_amt) from ded_temp b where a.cust_no = b.cust_no and a.ded_type_cd = b.ded_type_cd and a.chk_no = b.chk_no group by cust_no, ded_type_cd, chk_no)
16
17003
by: Philip Boonzaaier | last post by:
I want to be able to generate SQL statements that will go through a list of data, effectively row by row, enquire on the database if this exists in the selected table- If it exists, then the colums must be UPDATED, if not, they must be INSERTED. Logically then, I would like to SELECT * FROM <TABLE> WHERE ....<Values entered here>, and then IF FOUND UPDATE <TABLE> SET .... <Values entered here> ELSE INSERT INTO <TABLE> VALUES <Values...
2
8522
by: Mike Leahy | last post by:
Hello all, This question is related to updating tables - is there any way to calculate or update the values in a column in a table to the values in a field produced by a query result? An example of what I'm trying to do is below: update (tbl_ind_mananas LEFT JOIN (select count(*) as count, (dubicacion || zona || manzana) as cod_manzana from tbl_censo_poblacion_1993 group by dubicacion, zona, manzana) tbl1 on relacion = cod_manzana) as...
16
3866
by: robert | last post by:
been ruminating on the question (mostly in a 390/v7 context) of whether, and if so when, a row update becomes an insert/delete. i assume that there is a threshold on the number of columns of the table, or perhaps bytes, being updated where the engine just decides, screw it, i'll just make a new one. surfed this group and google, but couldn't find anything. the context: we have some java folk who like to parametize/
5
3531
by: PAUL | last post by:
Hello, I have 2 tables with a relationship set up in the dataset with vb ..net. I add a new record to the parent table then edit an existing child record to have the new parent ID. However when I do the update the changed parentid in the child table fails to change. No error is given its just that the change is not written to the Database. When I step through the records for the child table the one I would expect to be changed has a row...
2
3100
by: Miro | last post by:
I will ask the question first then fumble thru trying to explain myself so i dont waste too much of your time. Question / Statement - Every mdb table needs a PrimaryKey ( or maybe an index - i havnt tested the index yet ) so you can use an .UPDATE( dataTable ) on the data adapter. Otherwise you will get an exception error. Is this statement true? ---- Now me fumbling thru
1
4058
by: adithi | last post by:
My Table Structure is: Table A Table B Table C colA -PK Col B-PK Col C-PK Col B-FK Col B-FK Col C-FK This relation establish a Concurrent relation where in Cascade Property fails.I can set Cascade property for any two tabnles...but not the third table. My requirement is :
3
3950
by: Michel Esber | last post by:
Hi all, DB2 V8 LUW FP 15 There is a table T (ID varchar (24), ABC timestamp). ID is PK. Our application needs to frequently update T with a new value for ABC. update T set ABC=? where ID = ?
0
8231
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8168
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8672
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
7153
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5561
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4075
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4167
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1780
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1474
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.