?
Solved

In Grid editing nightmare

Posted on 2011-09-07
9
Medium Priority
?
365 Views
Last Modified: 2012-05-12
Hi all
i need to use "in grid" editing (something i never do) in the following scenario:
I have table1 where i enter employee schedules: employeeid, time_in, time_out
I also have Table2 with employee names: employeeid, lastname, firstname
Table1 is recordsource for the grid. In column1 i entered table1.employeeid, in column2 controlsource is allt(lastname)+" "+allt(firstname)  -- column2 is readonly, column3 controlsource is time_in and column4 controlsource is time_out.
The problem is that i cannot have the employee name displayed correctly in time . When entering new records, it will not update the name, or it will update the current name for all the others in the column etc...I tried using 2 employees tables - 1 with a relation set for displaying in the grid, and the other one for lookup when needed, still no go...tried playing with the sparse property of the column, but still nothing.
Table1 has buffermode 5.
How can i have it display correctly the names according to employeeid, particularly when adding a new line

Thanks for your help
Jaime

0
Comment
Question by:GreatSolutions
[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
  • 4
  • 3
  • 2
9 Comments
 
LVL 42

Expert Comment

by:pcelba
ID: 36494775
You may try the following column2 ControlSource expression:

(IIF(SEEK(THIS.Parent.column1.value, "Table2"), allt(Table2.lastname)+" "+allt(Table2.firstname), ""))

(I did not try it yet)
0
 
LVL 42

Expert Comment

by:pcelba
ID: 36494784
The value reference should probably be

THIS.Parent.column1.Text1.value
0
 
LVL 42

Accepted Solution

by:
pcelba earned 2000 total points
ID: 36494893
Hmm, THIS.Parent... does not work but

(IIF(SEEK(Table1.EmployeeId, "Table2", "employeeid"), allt(Table2.lastname)+" "+allt(Table2.firstname), " "))

works fine.
0
Independent Software Vendors: 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!

 
LVL 29

Expert Comment

by:Olaf Doschke
ID: 36496994
The last SEEK would also be doable as a relation between table1 and table2:

Set Order To employeeid in Table2
Select Table1
Set Relation To employeeid Into Table2

The code could be in form or grid init, anywhere the two tables are already open. And as Pavels SEEK solution, this needs an index on employeeid in Table2.

Column2.controlsource should be set to (allt(table2.lastname)+" "+allt(table2.firstname))

Including the outer parathesis. As you don't use a differing control you don't need to set column.Sparse=.F., this is just needed in cases you want the grid to draw a currentcontrol into any row, and not just the current row.

Controlsource values are never computed sparsely. if you see repeated value, this is normall just a side effect of a differing control, than the original Text1 Textbox of each grid column. In your case the repeating values simply come from table2 not being the recordsource of the grid, but VFP get's the field content of lastname and firstname from table2, from the same record, over and over again. That's why it's repeated.

As you said you tried a relation, what exactly did you try? It seems not to have worked. Have you perhaps set the relation from table2 to table1 instead?

Bye, Olaf.

0
 
LVL 2

Author Closing Comment

by:GreatSolutions
ID: 36501166
The simplest solutions are always the greatest!!!
Thanks again
0
 
LVL 2

Author Comment

by:GreatSolutions
ID: 36501176
Olaf, i did of course set relation from table1 to table2, that's why when viewing the grid all the data was always correct. The problem started when editing the grid and entering an employeeid value. Peter's solutions worked a treat in that case

Jaime
0
 
LVL 29

Expert Comment

by:Olaf Doschke
ID: 36501562
Well, Grid.Refresh() should update. Also a new employeeid only will take effect, once you left the field. Buffering may also lead to delayed reference.

But if it works, it works.

Bye, Olaf.
0
 
LVL 42

Expert Comment

by:pcelba
ID: 36501670
Hmm... This could also mean relations are not working correctly in buffer mode 5.

I cannot explain why relation did not work but SEEK is O.K. It would probably need some more investigations.
0
 
LVL 2

Author Comment

by:GreatSolutions
ID: 36504460
Exactly, at first i did run Grid.refresh() in the lostfocus() event of employeeid, but still was messy. SEEK worked great, i cannot believe i missed that method after 20 years of suffering :-)
0

Featured Post

How To Reduce Deployment Times With Pre-Baked AMIs

Even if we can't include all the files in the base image, we can sometimes include some of the larger files that we would otherwise have to download, and we can also sometimes remove the most time-consuming steps. This can help a lot with reducing deployment times.

Question has a verified solution.

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

Microsoft Visual FoxPro (short VFP) is a programming language with it’s own IDE and database, ranking somewhat between Access and VB.NET + SQL Server (Express). Product Description: http://msdn.microsoft.com/en-us/vfoxpro/default.aspx (http://msd…
This is a fine trick which I've found useful many times, when you just don't want to accidentally run a batch script or the commands needs administrator rights.
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
Suggested Courses
Course of the Month14 days, 23 hours left to enroll

771 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