Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Inserting Records In A Grid

Status
Not open for further replies.

Shanachie

Programmer
Jun 18, 2000
92
US
I need to find a way to insert records in a grid. These may need to be in the middle of the grid not at the end.

To fill out the problem a little: the grid contains detail lines in a purchase order, specifying items and personalizations. For example, there might be a line for 50 baseball hats, followed by a line for the team logo to be embroidered on the front (separate charge) and another line specifying the monogram to be sewn on the back. This could be followed by several lines specifying the team's shirts and their embroidery, silkscreening, etc. Several days later, perhaps the customer calls back and wants to add to the personalizatons for the hats. I need to insert a line back before the shirt lines. How? Add a line at the end (easy enough) and "move" it to where it belongs? How can I move it? Or is there an easier way?

I suggested that the client have the users add a line at the end and cut-and-paste, moving each item in each record &quot;down&quot; one line, thereby creating a &quot;blank&quot; line where needed. For some reason, they didn't like that solution. <g>

Suggestions?

Shanachie
 
Shanachie,
Since the grid is based on a table (or cursor), all you need to do is create an index such that it's &quot;sorted&quot; in the order you want. The index could be based on a visible value that user provides, or a &quot;hidden&quot; one that you control programatically.

Rick
 
You could use a SQL INSERT command to insert a record iso append a record.

HTH,
Weedz (Wietze Veld) They cling emotionally to code and fix development rather than choosing practices based on analytical assesments of what works best. - Steve McConnell
 
Thanks, Rick & Weedz, that helped. I used both of your suggestions in my solution. But that's brought me to another problem.

I added a text control that lets the user input the number of the record to insert after (to get the blank grid line in the right place) and a button that does the insertion after incrementing the line number for all records with line numbers higher than the user input indicates. It does that fine; looks right, saves right.

Now I've got a problem with the grid being confused about which line it's on. When the user enters the quantity and the unit price (on any line), the lost-focus event for the unit price text control calculates the extension (e.g., 10 ballhats @ $9.25 = $92.50) and refreshes the form. The problem is that when it does that on the inserted line, control jumps to the last line of the grid, which is where in the table the inserted line actually resides.

How do I get it to stay on the inserted line or to return to the inserted line? Could I assign the grid's active row attribute?

TIA
Shanachie
 
Oops, guys, I goofed. The described behavior was due to something else entirely. Vestigal code from an earlier experiment. Deleted it and it now works fine.

Thanks again,
Shanachie
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top