[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

In Grid editing nightmare

Posted on 2011-09-07
9
Medium Priority
?
371 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 43

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 43

Expert Comment

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

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

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

 
LVL 30

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 30

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 43

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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

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…
With the evolution of technology, we have finally reached a point where it is possible to have home automation features like having your thermostat turn up and door lock itself when you leave, as well as a complete home security system. This is a st…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Suggested Courses

649 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