By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,364 Members | 1,536 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,364 IT Pros & Developers. It's quick & easy.

adding records to a table

P: n/a
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.ItemData(cboDept.ListIndex)
!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
Share this Question
Share on Google+
1 Reply


P: n/a
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.ItemData(cboDept.ListIndex)
!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 discussion thread is closed

Replies have been disabled for this discussion.