Solved

datagrid

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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…

746 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now