Solved

add new record in TDBGrid

Posted on 1998-03-01
4
402 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

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…
Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
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…
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…

726 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