473,732 Members | 2,043 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

adding records to a table

Hi All,

I have a problem of adding records into table, if the cursor is on the first
record the record that I add replaces the first record and then I moved it to
the last record and the new record replaces that last record in the table.
Is there a method that I can use to make sure this doesn't happen. The thing
is my program was working fine until recently, as I have about 197 records in
that table. Can someone please rescue me.
this is the code that I use to add the record:

On Error GoTo AddErr

With rsemp
If bAddNew Then .AddNew
!empnum = txtEmpNum
!EmpDeptId = cboDept.ItemDat a(cboDept.ListI ndex)
!Title = cboTitle
!lastname = txtLastName
!firstname = txtFirstName
!offloc = cboOffLoc
!officenum = txtOffNum
!OffPhone = Me.txtPhone
!email = txtEmail
.Save
End With
cmdAdd.Enabled = True

cmdSave.Enabled = False
Exit Sub
AddErr:
MsgBox "there was an error " & Err.Number & " " & Err.Description
End Sub
Nov 21 '05 #1
1 1124
Nkagi,

Is this VBNet code?

And when it is can you than make it more understandable for somebody who has
not the rest of your program.

By instance

What is rsemp?

Why using "with" while you only use the dot two times in the routine?

Why not using VBNet errorcatching?

Cor.
On Error GoTo AddErr

With rsemp
If bAddNew Then .AddNew
!empnum = txtEmpNum
!EmpDeptId = cboDept.ItemDat a(cboDept.ListI ndex)
!Title = cboTitle
!lastname = txtLastName
!firstname = txtFirstName
!offloc = cboOffLoc
!officenum = txtOffNum
!OffPhone = Me.txtPhone
!email = txtEmail
.Save
End With
cmdAdd.Enabled = True

cmdSave.Enabled = False
Exit Sub
AddErr:
MsgBox "there was an error " & Err.Number & " " & Err.Description
End Sub

Nov 21 '05 #2

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

Similar topics

5
5285
by: Sue | last post by:
On code-behind page: (attributes set programatically for each of these elements) linkbutton added to tablecell textbox added to tablecell tablecells added to tablerow tablerow added to table (table.ID is TestTable) On .aspx page: <HeaderTemplate> <asp:Table ID="TestTable" runat="Server" /> </HeaderTemplate>
6
2410
by: Jamie Fryatt | last post by:
Hi everyone, here's what id like to do. I have a table with 2 fields, name and value I need to be able to add multiple records quickly, for example I need to add name value abc 1 abc 2 abc 3
3
4906
by: Raj | last post by:
Hi, I am trying to add some more information to the table which already has a lot a data (like 2-3000 records). The new information may be adding 2-3 new columns worth. Now my questions are: (1)Is it a good idea to add new columns to the existing table? then it will create these new columns for all old records, will it not result in wasting a lot of space?? (2)Is it a good idea to create a new table with the new information and have as a...
6
2505
by: Robin S. | last post by:
**Eric and Salad - thank you both for the polite kick in the butt. I hope I've done a better job of explaining myself below. I am trying to produce a form to add products to a table (new products). Tables: tblCategoryDetails CategoryID SpecID
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
3
4879
by: Jim Heavey | last post by:
Trying to figure out the technique which should be used to add rows to a datagrid. I am thinking that I would want an "Add" button on the footer, but I am not quite sure how to do that. Is that the best method? Do you have a sample of how to do this?
6
4429
by: Rudy | last post by:
Hi all, I know this is easy, just can't seem to get it. I have a windows form, and a text box, with a value already in it. I need to add that value to a table. It's just one value, so the entire row doesn't get filled. I have a connection and all that stuff. Private Sub btnPlaceBet_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnPlaceBet.Click ' Dim Myds As Footbet.DStable '...
1
2509
by: vbDavidC | last post by:
I am adding a new record to a table via a dataset/adapter. I have got the following to work for me but I am wondering if there is a better way to do this. I am having to have something in my DS before I can add records, since DS does not exist. I'd rather not have a SELECT since I really don't need any records in my dataset that I will be adding a new record to. Dim dsNewRow As DataRow
2
1245
by: darrel | last post by:
HI vb Wizards, good day, just wanted to ask if somebody there can help me iwth my problem. Am having difficulty in adding up records in my table, the table is in Microsoft Access format. It Like this when i run my program, there no conflicts at no error pop up message or anything. but not satisfied with the outcome, here my code: Private Sub Command3_Click() Dim rsShowRec As New ADODB.Recordset Dim cnn As New ADODB.Connection Set...
2
3738
by: Steve | last post by:
I have zero experience with ODBC. If I have an Access frontend connected to a SQL Database using ODBC, are the tables connected like a frontend/backend Access database where the the tables you see in the frontend are only "copies" of the tables in the backend? Or ar the tables "real" tables connected to the SQL tables in some manner? If the latter, can an Access table have more fields than the SQL table it is linked to? The reason for my...
0
8944
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
9306
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9234
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
8186
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
6733
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
6030
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
4805
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2721
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2177
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.