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

Issue with a blank form

Status
Not open for further replies.

tforr

Programmer
Aug 14, 2003
181
0
0
GB
Hi does anyone have any idea how to have a blank form when a form is selected and opened even though there is data in the tables. At the moment I am unable to achieve this. I want it blank until I search for a specific record.

Thanks and kind regards,

Tom
 
Tom,
Suggest you insert a blank reccord on reccordnumber 1 and have your recordpointer at recn(1)
Koen
 
Right Koen that sounds like a good idea I will give it ago. By the way how would I pint to it. Sorry i'm a bit of a novice.

Thanks again,

Tom.
 
Include the NODATA on the USE statement. The table will be opened and you can access the form. The first time you search open the table with data.



Jim Osieczonek
Delta Business Group, LLC
 
Where can I find this use statement Jim
 
Just to make sure I am following you. Typically, I open / access a table with code like this.

IF NOT USED('customer')
SELECT 0
USE customer
ELSE
SELECT customer
ENDIF

In your situation, you want to open the table (using the USE statement) and include a parameter telling NODATA.

USE customer NODATA

When you access the form, the text controls will have nothing in them. This prevents an error (if you specified a control source) and brings up the form "empty".

This practice is common when running on a database server (either views or tables) because it prevents the data from being sent down the pipe unless you need to access it. The first record is rarely the one we need at any given time.


Does this help?


Jim Osieczonek
Delta Business Group, LLC
 
Jim,
The only problem with NODATA, is that it only applies to Views - not tables.

Rick
 
So should I use views instead of what I'm doing at the moment?
 
Gee, I never realized that. When I tried it worked, or at least I thought it worked because it did not give me an error. However, when I typed browse the data was there.

Jim Osieczonek
Delta Business Group, LLC
 
I have used the following code in the init event of a form to blank the text boxes. We have no record with 0 as the customer number.

select customer
set order to custnum
seek 0
return .T.
thisform.refresh

I'm still learning VFP myself, so maybe someone with more experience can tell us if this is a good idea or not.

David
 
Okay, I thought of another solution.

Step 1
Open your form and create a new property, I'll call mine data

Step 2
Add code in the INIT EVENT of the form

* Something like this...

USE c:\$temp\customer
SCATTER NAME thisform.data BLANK

* messagebox just for demo purposes
MESSAGEBOX(thisform.data.city)

* The form property has been intialized as blank.

3. Set the control source of the text field city (txtCity) to THISFORM.data.city

Once the user navigates to a record you wish to display, issue this command:

SCATTER NAME thisform.data

* messagebox just for demo purposes
MESSAGEBOX(thisform.data.city)



Jim Osieczonek
Delta Business Group, LLC
 
Well one more "funny" solution. Open the table, go bottom and then SKIP +1. There is a pseudo empty record there beyond the last record at EOF - you can't return values or store anything, but it should allow you to show an empty form!

Rick
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top