×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

HOW CAN I REPON A GRID THAT ALIAS DBF WAS CLOSE AND REOPEN

HOW CAN I REPON A GRID THAT ALIAS DBF WAS CLOSE AND REOPEN

HOW CAN I REPON A GRID THAT ALIAS DBF WAS CLOSE AND REOPEN

(OP)
HI TO EVERY ONE.
I HAVE FORM AND A GRID ON THAT . I NEED TO WHEN FORM IS OPEN , CLOSE DBF ALIAS OF GRID AND REOPEN IT WITH SELECT COMMAND. BUT WHEN TABLE WAS CLOSED AND CREATE AGAIN, THE GRID WAS CLEARED AND NEVER SHOW THE CONTENT OF NEW TABLE AGAIN. HOW CAN I REPAINT OR REOPEN THAT GRID AND USER CAN ACCESS TO GRID DATA?

RE: HOW CAN I REPON A GRID THAT ALIAS DBF WAS CLOSE AND REOPEN

Before you run the SELECT command, set the grid's RecordSource to an empty string. Then do the SELECT. Then set the RecordSource to the alias of the cursor produced by the SELECT.

You don't need to explicitly close the DBF.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads

RE: HOW CAN I REPON A GRID THAT ALIAS DBF WAS CLOSE AND REOPEN

(OP)
THANK YOU MIKE
I AM WORKING IN FORM DESIGNER USUALLY AND WHEN ADD GRID TO FORM, IN PROPERTIES OF EVERY COLUMNS WRITE THE FIELD NAME (AND COLOR AND FONT AND WIDTH AND SO ON) OF MY TABLE AND I DO NOT WRITE ANY COD FOR MY GRID. AT SOME TIMES I NEED TO CLOSE DATA TABLE WHEN FORM AND GRID IS ACTIVE (WITH ANY REASON). HOW CAN I REFRESH MY GRID WITH LAST CONFIGURATION IN FORM DESIGNER?

SELE 0
USE MTABLE
ACTIVATING FORM
ACTIVATING GRID IN IT
WHEN USER PRESS X PUSH BOTTOM I MOST CLOSE TABLE AND RE-CREATE IT
IN THIS TIME GRID WAS CLEARED AND DOES NOT SHOW ANYTHINGS
THEREFOR MY FORM IS USELESS AFTER PRESSING POSH BOTTOM


RE: HOW CAN I REPON A GRID THAT ALIAS DBF WAS CLOSE AND REOPEN

Unless you're allowing the user to edit in the grid, the best thing to do is to put the data in a cursor (by using SQL SELECT) and use the cursor as the grid's RecordSource. Then, if you need to close the original table for some reason, the grid will be unaffected.

If the issue is that the table might get changed in some way from somewhere else and you want the grid to show those changes, then you want to use the technique generally called "Safe Select." To do that, you create a cursor (probably in the form's Load event) with the columns you need. Then, to fill it, you using code that issues the SELECT into a different cursor and then ZAPs and copies into the one for the grid. Here's more information on that technique: http://fox.wikis.com/wc.dll?Wiki~GridSafeSelect

Tamar

RE: HOW CAN I REPON A GRID THAT ALIAS DBF WAS CLOSE AND REOPEN

(OP)
hi tamar

thank you for your help and sorry for delay of my answer
I will do your technique and test the result. I hope solve my problem.

I think my weakness is when i create a form and grid on it , firstly use a master table for source of grid and i can not zap or delete it and this is mistake , and second i do all setup of grid in properties and NOT source code. therefore when I need to close and reopen the table, my grid column field name and color and font and header and ... will be lost.

with best regards

RE: HOW CAN I REPON A GRID THAT ALIAS DBF WAS CLOSE AND REOPEN

It's fine to set up your grid in the property sheet, but to do so, you should use a cursor and the safe select technique I suggested.

Tamar

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close