Solved

add new record in TDBGrid

Posted on 1998-03-01
4
406 Views
Last Modified: 2012-06-27
hi, I have a VB program to connect to SQL database using RDO. in my application, I use TDBGrid to browse the records.
I have all MoveFirst, MovePrevious, MoveNext, MoveLast buttons working properly, But I have the following errors:
1. I want to have a New button, It bring me to the new row, but It doesn't hightlight(focus) in the first column so that I can type in without moving the mouse to there and click on it. How can I do that? routines will be helpful, sample codes even better.

Thank you

Chris Leehi, I have a VB program to connect to SQL database using RDO. in my application, I use TDBGrid to browse the records.
I have all MoveFirst, MovePrevious, MoveNext, MoveLast buttons working properly, But I have the following errors:
1. I want to have a New button, It bring me to the new row, but It doesn't hightlight(focus) in the first column so that I can type in without moving the mouse to there and click on it. How can I do that? routines will be helpful, sample codes even better.

Thank you

Chris Lee
0
Comment
Question by:ny971181
[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
  • 2
4 Comments
 
LVL 6

Expert Comment

by:anthonyc
ID: 1458222
you can try this in the new buttons click event...

tdbgrid1.setfocus
tdbgrid1.column = 0
0
 
LVL 1

Author Comment

by:ny971181
ID: 1458223
Oh, my god!
first of all, your answer is straight forward wrong!
second, no explanation on your code!


I figured this answer out last night. Here is something else I need you guys help me out:
I made a new button, It works well: It places the cursor on the first column as I wanted once I hit it. Then I entered my data. Now, My problem is when I finished data entry, I have to click on other rows so that new data is saved on the resultset. but if I hit the close button of the windows, It says: No Current Row.
If I hit the movefirst of movenext button, It gives me the same error. So Now I like to have a save button so that when I finished data entry, I could hit save to save(update) the recordset.

Thank you very much and have a nice day!

chris Lee
0
 
LVL 6

Expert Comment

by:anthonyc
ID: 1458224
am I supposed to help you with your attitude?  Smartass, the example I displayed worked no problem with dbgrid.  If it didn't work with tdbgrid, then tough.  I don't appreciate your attitude, and have no intention on helping you with your next problem, although I do know the solution.  
0
 
LVL 1

Accepted Solution

by:
sachinkas earned 20 total points
ID: 1458225
Hi

You can stop the user by giving
in the form unload

if tdbgrid1.datachanged=true then
   msgbox "Record filling incomplete"
cancel=true
endif

0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
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…

729 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