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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Command button that browses data

Status
Not open for further replies.

dale3972

Programmer
Feb 6, 2014
23
US
Hello again. In creating this new vfp9 form from a 2.6 program, I have several buttons that are supposed to browse particular data. Keeping it simple: I have command button that is supposed to pull up the main data. In the click event I have - Do browcase.prg. What is happening is that its filling my screen with a huge blank browse table, nothing in it, but displaying a record number at the bottom.

Now before I open my main form, I run this browcase.prg and to select a record and it works fine. Here is the code of browcase program:

PROCEDURE browcase
SELECT CASE
PRIVATE lnrecno, lndefid
lnrecno = RECNO()
lndefid = case.def_id



ON KEY LABEL rightmouse KEYBOARD(CHR(23))
BROWSE COLOR SCHEME 10 NOEDIT NODELETE NOAPPEND;
FONT 'TIMES NEW ROMAN', 8 STYLE 'N' TITLE;
'<Ctrl-W> Select <Ctrl-Enter> Case Summary <Ctrl-P> Print Arrest Record <ESC> Return' ;
FIELDS defendant :30, CASE, warrant, gj_number :H='GJ #', gj_pdate :H='GJ Date', agency_no, agency : H= 'Agency', dc_no :H='DC #', mc_chrgs.charge, ;
victim.vic_name :H='Victim',;
attor_id :H='ADA ', cc_no :H='CC #',;
defendant.race, defendant.sex, defendant.dob :H='DOB',;
warrant, warr_date :H='Warrant Date', defendant.sid :H='SID'

IF LASTKEY() = 27
GO lnrecno
ENDIF
ON KEY LABEL ctrl+enter
ON KEY LABEL ctrl+p

RETURN

Why does the button not run to run this program correctly at the click event?

Thanks in advance! Trying to get this in some kind of working order by tommorrow :)
 
Why don't you do this: (OOP style)

Create a form (which you have done)

Drop a Grid control on it and use the grid builder to display the data, and you can make it readonly and change all kind of nice features and fonts and color and things on it.


Ez Logic
Michigan
 
I thought about that idea. But the form itself is filled with buttons and text fields and includes four page frames. While I indeed increased the size of the form from the original tiny 2.6 form. I wonder if there is a way to maybe call the grid from a command button? I am trying to keep this like the original as possible while making everything bigger and more pleasing to the eye. Some of these people have worked in these offices for over twenty years and are not so computer savvy. They just want it to work like the old. The new computer systems they are getting is causing me to have to upgrade.

So thanks for the idea. I will play with that. But is there a work around I could use to call the browse from the button? Am I doing it wrong calling a procedure from the click event? Is there something else I need to do to the object button? Why is it working before I open the form?

Thanks again.
 
Ok. Now I don't have the program open. The databases are pen. When I go to data session from the window menu and hit browse on any of the databases - Same thing happen ---- A huge empty browse screen that only shows the number of record its on. I am just in the work area of visual fox pro. Something must have happened for it to do this. I bet if I restart vfp and open up the program and close it without hitting the browse button. It will be normal again. This is confusing.
 
Sure enough. I restart visual foxpro. Opened the application. Closed it without hitting my command browse button. The I went to data session and browsed the database and all was find. I opened the application again, the program browcase worked before the form was opened, but when I hit the browse command button I made in the form that called for the browcase.prg in the click event - a huge blank grid empty data screen appears covering everything. I quit my app. I open the data session and browse - same huge blank empty data screen, obviously with records as the display says record 334 of 23009. Help! lol
 
Slow down, cowboy. Take deep breaths.

When you say "go to the data session" do you mean the Data Session window or something else? (DataSession is actually a "thing" in VFP code.)

Basics: VFP allows <x> (255?) work areas, nominally. But that gets perverse because you can have multiple DataSessions, *EACH* having its own independent set of work areas. (This is a good thing even though it's confusing.)

It's very easy to have data open for a Browse, and then run a form using an entirely different data session so things aren't set up the way you thought before you run the form!

Breathe.
Throw away what you thought you knew and don't try to make VFP work that way.
Breathe.
It's easier than what you're doing.
Breathe.

If you see an empty grid it means a couple of specific things:

* The table is empty
* The table has a filter that keeps it from showing records
* The table has a BROWSE KEY that prevents it from showing records
* The grid isn't using the alias you think it is

Grids (and browses are just grids in the innards) are smart and dumb at the same time. On the one hand they just display what you tell them to display. On the other hand, they listen to you.
 
Thanks :) When I quit the app and go into the data session window on the visual foxpro menu, the tables open in the same way. All of them - One big giant grid with nothing on it, but showing a record count at the bottom. When I restart foxpro and open the app, the browcase program works at start up (showing me a list of cases as normal). It is when I go into the form and hit the command button I created that simply states - do browcase.prg in the click event is when the mess happens. So either I can't run the same program from a command button or I am not setting up the command button right. Could be an index issue. But I have set the order in the browcase program.

So when I open the app it immediately browses and then opens up the form. When I click on the Browse button I made it messes up the main database and database related to it. And they are still messed up after I exit the app. I have to restart Fox Pro.

This lady is going to panic tommorrow if I don't have something, so what I am going to do is recompile a functional version of her two main interface screens in visual and let her use that not so pretty app, until I can get a grip on this new OOP or whatever. It was all going so well until I started testing the browses and ....uggh I will not even go into the Complex Add New Case button I made. I will figure it out.

Thanks for all the help!
 
When I quit the app and go into the data session window on the visual foxpro menu, the tables open in the same way.

The Data Session Window does not open tables all on its own so we can assume you're doing something here. What do you mean by "in the same way"?

All of them - One big giant grid with nothing on it, but showing a record count at the bottom.

Yes, that sounds like the data session window. It's just a list of currently open tables and is provided mostly as a debugging tool. It should not have anything to do with your application.

When I restart foxpro and open the app, the browcase program works at start up

Yay! The program works! What do you mean by "open the app"? Apps are not like Word documents. You do not open them. You run them.

Further, your app should exit Foxpro on shutdown. That may actually be your failure here. If your app is leaving flotsam in the environment it may be messing with subsequent efforts. There are ways for your app to clean up after itself, but it's sounding like that isn't happening here.

You appear to be describing entire sessions as if it's one (or 12) action(s). It isn't. We can't peer over your shoulder. We can't see through your eyes.

Tell us step-by-step what you do, and what you see, and why it's wrong. Someone may have an idea.
 
I think your relation got reset or lost. Set the relations in this program.

Nasib
 
Thanks again Dan.

I am working in visual foxpro the whole time. The command window is open. The project is open. I run the application from the command window.

In the main program code, in the project of my application(my program that will run on the clients computers) , I have a line that reads Do browcase.prg, which opens a browse like I want. I select a record then it enters the main form, my main input screen, what I would call my application. So lets call this my Main Case Application.

I inserted a command button on my main form and called it Browse. In the click event of that button, I put Do browcase.prg. When I click that button I get an empty grid screen, not at all like the one I just saw when I first ran the application. I quit the application from the applications menu and I am now in my Visual Foxpro work area. I open up data session from the window menu and it lists the databases that are still open from my application. I am now completely out of my Main Case Application. When I click on one of the databases in the command window, either the main database, or any database linked to it, I get the same blank grid screen and I see a record count at the bottom, so I know there are records. I have to restart visual foxpro begin again.

I am apparently setting up the command button wrong.

My customers are still using 2.6 so I am trying to rebuild the Main Case Application. They are running several machines off a server. One of the girls just got Windows 8.1 with no hyper V. I have been working on this rebuilding for quite some time now and have some beautiful forms made. Now things are happening quickly. I bought myself more time by just converting her old 2.6 program into visual using function conversion but it is small and ugly. But it will work in a pinch I hope.

Thanks again!
 
Did not see your post NasibKalsi. I will check that out as well. Thanks!
 
what can blank a brows window:

SET FILTER
SET KEY
A RELATION not finding child records

In the datasession window you should see relations visualized, both 1:n and 1:1 relations. Browse the main/root table before browsing a child to get to the correct parent and have child records displayed.

Bye, Olaf.
 
You're making this unnecessarily hard by trying to use Browse in a program. If you want something that looks like Browse, but is much easier to control, create a form that contains just a grid, sized to fill the form.

Tamar
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top