?
Solved

add new record in TDBGrid

Posted on 1998-03-01
4
Medium Priority
?
412 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 40 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

[Webinar] Lessons on Recovering from Petya

Skyport is working hard to help customers recover from recent attacks, like the Petya worm. This work has brought to light some important lessons. New malware attacks like this can take down your entire environment. Learn from others mistakes on how to prevent Petya like worms.

Question has a verified solution.

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

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…
Suggested Courses
Course of the Month8 days, 20 hours left to enroll

764 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