473,721 Members | 2,263 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

back to basics, adding and editing Table records from a Form, proper procdures

RC
I have an Access 2002 database with many tables and forms (but just to
keep things simple, let's say the DB has one Table "Table1" and one
Form "Form1").
I have managed to cobble together so much complex code to add records
and edit records I need to step back and ask you all what is the
proper way to do this. The database is DAO. The table has Columns
SerialNumber, CPU, HardDrive and Model. I am trying to use a Form to
fill out the Table values. Each SerialNumber needs the CPU, HardDrive
and Model to be specified. I am using a Form with the Form's record
source set to Table1. On the Form I dragged and dropped the
SerialNumber, CPU, HardDrive and Model fields from the fields list to
the Form.
What is the proper way to add a new record and also what is the proper
way to update an existing record. Should the SerialNumber form field
have a FindFirst set to look for the Serial Number and if the
SerialNumber is not found, then ?? rs.addnew? rs.edit then
rs.Fields("CPU" ) = me.CPU.value? etc., and then rs.update? Most of
the information will be the same from Serial Number to Serial Number
so it would be nice if the Form fields could retain the last value
that was entered in them so that when the next serial number is typed
into the SerialNumber box, you would only need to change whatever is
different not enter a value in each form field again. The table
field/columns are all text. Should I use code like this?
Dim db As DAO.Database
Dim rs As DAO.Recordset
Set db = CurrentDb
Set rs = Me.Recordset
rs.FindFirst "[SerialNumber] = " & Me.SerialNumber Box

If rs.NoMatch Then ??? '(the rs.edit? or rs.addnew?
Me.Bookmark = rs.Bookmark ??? "Do I need to this? Where does it
belong?
rs.edit
rs.Fields("Seri alNumber") = me.SerialNumber .value
rs.Fields("CPU" ) = me.CPU.value
rs.Fields("Hard Drive") = me.HardDrive.va lue
rs.Model("Model ") = me.Model.value
rs.update

what about rs.movelast ??
rs.close
set rs = nothing

Thanks for the help.
Nov 13 '05 #1
1 2129
rc*********@yah oo.com (RC) wrote in message news:<3c******* *************** ***@posting.goo gle.com>...
I have an Access 2002 database with many tables and forms (but just to
keep things simple, let's say the DB has one Table "Table1" and one
Form "Form1").
I have managed to cobble together so much complex code to add records
and edit records I need to step back and ask you all what is the
proper way to do this. The database is DAO. The table has Columns
SerialNumber, CPU, HardDrive and Model. I am trying to use a Form to
fill out the Table values. Each SerialNumber needs the CPU, HardDrive
and Model to be specified. I am using a Form with the Form's record
source set to Table1. On the Form I dragged and dropped the
SerialNumber, CPU, HardDrive and Model fields from the fields list to
the Form.
What is the proper way to add a new record and also what is the proper
way to update an existing record. Should the SerialNumber form field
have a FindFirst set to look for the Serial Number and if the
SerialNumber is not found, then ?? rs.addnew? rs.edit then
rs.Fields("CPU" ) = me.CPU.value? etc., and then rs.update? Most of
the information will be the same from Serial Number to Serial Number
so it would be nice if the Form fields could retain the last value
that was entered in them so that when the next serial number is typed
into the SerialNumber box, you would only need to change whatever is
different not enter a value in each form field again. The table
field/columns are all text. Should I use code like this?
Dim db As DAO.Database
Dim rs As DAO.Recordset
Set db = CurrentDb
Set rs = Me.Recordset
rs.FindFirst "[SerialNumber] = " & Me.SerialNumber Box

If rs.NoMatch Then ??? '(the rs.edit? or rs.addnew?
Me.Bookmark = rs.Bookmark ??? "Do I need to this? Where does it
belong?
rs.edit
rs.Fields("Seri alNumber") = me.SerialNumber .value
rs.Fields("CPU" ) = me.CPU.value
rs.Fields("Hard Drive") = me.HardDrive.va lue
rs.Model("Model ") = me.Model.value
rs.update

what about rs.movelast ??
rs.close
set rs = nothing

Thanks for the help.

My guess is that you could probably do most of this by just changing
the default values for the relevant fields right on the form. Doing
all this is probably more trouble than it's worth...
Source: http://www.mvps.org/access/forms/frm0012.htm

Carry current value of a control to new records
Author(s)
Dev Ashish

(Q) How do I carry forward the current value of a control so that
it's automatically entered for all new records?

(A) To use the curent control value for new records, you need to
assign it to the defaultvalue of the control. For example something
like

'******** Code Start **********
const cQuote="""" 'Thats two quotes
me!Control.Defa ultValue = cQuote & me!Control.Valu e & cQuote
'******** Code End **********

would carry the current value of the control forward if you place
this code behind a command button to conditionally run it.
HTH
Pieter
Nov 13 '05 #2

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

Similar topics

4
3665
by: webhigh | last post by:
I¹m not sure if this a PHP question or an MySQL question but here it goes. I have a repeat region of a table called userid What I¹m trying to accomplish is being able to edit the record and then update it by clicking a submit button on the same line. I¹m doing it this way so the user can quickly update a number of records one at a time. I know I could do this by passing the userid info to a detail page but really want to do it the way...
4
1986
by: Belinda | last post by:
Hello All I need to read a SQL Server table into a Web Page and within the Web Page to permit my users to make changes to the records, delete or add new records and then save the entire contents back to the SQL Server table back. The functionality I am looking is almost the same as In the SQL Enterprise Manager whereby I can choose a table open the table and then return all rows and I can maintain the same and save it back to
2
1325
by: j.mandala | last post by:
Various versions of my app have been in use for the last 5 years or so (in Access 97, 2K and XP editions). To upgrade the back end for people I have to add fields to some tables, some new indexes, and a few tables. I have been looking at the dbUpgrader demo (the ActiveX device), but have not been able to get it to work. Before I spend a lot of time on this I was wondering if anyone had any suggestions on whether this is worthwhile or if...
2
2622
by: David | last post by:
Hi, I have an order form which has a field 'ProductID'. This form has a button on each record to open a new form linked by ProductID. This new form is a continuous form and obviously, only displays the records associated with that ProductID. Basically this is part of a Product Packing Pick System. From my products table, each product has a set default amount of items which
5
4699
by: Mike Turco | last post by:
What is the difference between creating relationships in the front-end vs. the back-end database? I was trying to create a relationship in a database front-end and noticed that I could not check the referential integrity box. What gives? Continuing on with that line of thinking, I understand what do the relationships do for you in a database, but what do they do physically to the tables? Thanks,
24
2787
by: Bob Alston | last post by:
Most of my Access database implementations have been fairly small in terms of data volume and number of concurrent users. So far I haven't had performance issues to worry about. <knock on wood> But I am curious about what techniques those of you who have done higher volume access implementations use to ensure high performance of the database in a multi-user 100mbps LAN implementation??? Thanks
1
1718
by: JohnR | last post by:
I'm using oledb to an Access datatable. I load the table into a dataset. I create databindings to link the fields on my form to the corresponding fields in the datatable. The tables DefaultView.Sort is set to the field that is bound to a dropdown (where I can pick what record to view, and the dropdown list is sorted). I click a rec in the dropdown, and all the values of that record then populate the fields on my form. Editing, and...
5
1548
by: Neo Geshel | last post by:
Greetings. I am in a very big pickle. I am trying to add page content - as well as a submit button - programatically to a web form that is supposed to submit to DB and then refresh. That is, a user goes to the web page, which draws the current content out of the db and inserts into a "preview" area as well as the form itself. User makes changes, hits submit button. The page *should* refresh, with the changes saved to the db, and...
8
6078
by: Penny | last post by:
(Access 2003 Multiuser Split DB, Windows XP Pro) Hi All, I would really appreciate just some basic tips on how to make a Crosstab Form based on a Crosstab Query. The query always has the same number of records(generated from a table of predefined 'timeslots'). The number of columns(one for each Consultant) varies depending on how many of the Consultants have a yes/no field('Participates') set to yes. Therefore the Crosstab query...
0
8858
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
9376
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...
1
9148
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8026
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...
1
6678
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5994
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
4499
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...
1
3207
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2146
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.