Solved

datagrid

Posted on 2000-03-18
3
250 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
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 50 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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
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…
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

786 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