Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

add new record in TDBGrid

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

Tech or Treat!

Submit an article about your scariest tech experience—and the solution—and you’ll be automatically entered to win one of 4 fantastic tech gadgets.

Question has a verified solution.

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

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 …
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 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…
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

618 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