?
Solved

datagrid

Posted on 2000-03-18
3
Medium Priority
?
256 Views
Last Modified: 2010-05-02
i have a DataGrid control in a form and 2 buttom one is addnewe record the second is delete record.
how to put a code for evry button
whne i press add move cursor to new cell and write the new record.
and when highlight row and press delete
delete it from database and datagrid
?
thnx yaco
 

0
Comment
Question by:yaco
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 1

Expert Comment

by:simonstre
ID: 2631647
why don't u use another form with txtboxes to get ur information, with three buttons at the bottom (add, edit, delete)? u could validate the data by the same occasion...
0
 

Author Comment

by:yaco
ID: 2632282
yes i can use it by form
but need to be in a grid can u help me
0
 

Accepted Solution

by:
siewling earned 100 total points
ID: 2638237
Yaco,
    I have done a similar task as yours, thus I hope this solution will help you:-

Private Sub cmdAdd_Click()
  On Error GoTo AddErr
  datPrimaryRS.Recordset.MoveLast
  grdDataGrid.SetFocus
  SendKeys "{down}"

  Exit Sub
AddErr:
  MsgBox Err.Description
End Sub

Private Sub cmdDelete_Click()
  On Error GoTo DeleteErr
  With datPrimaryRS.Recordset
    .Delete
    .MoveNext
    If .EOF Then .MoveLast
  End With
  Exit Sub
DeleteErr:
  MsgBox Err.Description
End Sub
0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Suggested Courses
Course of the Month13 days, 9 hours left to enroll

800 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question