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

Block pop up from select statment 1

Status
Not open for further replies.

makdu

Programmer
Aug 15, 2009
22
KW
Hi,
I am creating a form. To this form the values are filled from a foxpro table( foxpro 6.0). I have used select statment
Code:
SELECT fname,lname,dob,nation,gender,married,contactno,doj,salary,commision,division	from employee where empid=lclempno
then using the values obtained , i am filling the text box with names, dates etc.
The problem is that when i use this command, the table with result of select statment is popingup, which i need to avoid. Is there a way for just getting the values of the table to some variable and using that to fill the textbox without this popingup.
 
Yes, this is very easy.

What you are seeing is a Browse window, which shows the data selected from your query. This is the default behaviour.

To avoid it, add either INTO CURSOR or INTO ARRAY to the end of the query, followed by the name of a cursor or array. The query results will then be sent to that destination, from where you can access them in your form. You won't see the Browse window.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro tips, advice, training, consultancy
Custom software for your business
 
Like this:

Code:
SELECT fname,lname,dob,nation,gender,married,contactno,doj,salary,commision,division    from employee where empid=lclempno into cursor mycursor



Regards

Griff
Keep [Smile]ing

There are 10 kinds of people in the world, those who understand binary and those who don't.
 
Looking at this a bit closer, you say you're using the results of the SELECT to populate the controls on the form.

Possibly a simpler approach would be to set the ControlSource property of each control to the alias.name of the relevant field. Your code would then be something like this:

Code:
SELECT Employee
LOCATE FOR EmpID = lcEmpNo
THISFORM.Refresh

This will automatically populate the controls, without any further code.

Note that if the user then edits the control, the edit will update the underlying table. If that's not what you want, make the controls read-only.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro tips, advice, training, consultancy
Custom software for your business
 
If i want to close a form using a command button, what is the code needed in the command button.
 
I want to delete a record from a table and the deleted record has to be copied to another table.
I tried using
Code:
SELECT  * into  deletemprcd  from employee where  empid =lclempno
but getting syntax error
Here i want to delete a record from employee table with a specific empid and before deleting , i want to copy all the equivalent data in employee table to another table, deletemprcd.
What needs to be done
 
Makdu, I see you are new to these forums, so I hope you don't mind if I make a couple of suggestions.

First, start a new topic for each question. You started this topic by asking about stopping the Browse window from a SELECT. That's fine. You then asked about how to close a form, and now you are asking about deleting and copying records.

These are all valid questions, but you'll get a better response if you make each one a separate topic, especially if you write a topic title that describes the nature of the each separate problem.

That way, you'll make it easier for people to know whether they can answer a given question. It'll also help people with a similar problem find the topic.

Secondly, it's curteous to respond when you receive an answer. You received two answers to your original question, but your only response was to ask another question. You then received an answer to that one, and you replied by asking a third question. It's much more useful if you could tell us if the answer was helpful or if it solved the problem. That way, other people with the same problem can benefit, and it also helps all of us learn.

I hope you don't mind me making these suggestions. This forum is an excellent place to get answers to Visual FoxPro questions, but you've got to work within its methods.

Mike


__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro tips, advice, training, consultancy
Custom software for your business
 
One more bug.
I have used cursor as suggested in the prevoius post
Code:
SELECT civilid,fname,lname,dob,nation,gender,married,contactno,doj,salary,commision,division,empsnap,address;
	from employee where empid=lclempno into cursor mycursor
Suppose i have 5 record, and i am searching for 5th record. after the code is run, the first record is modified with 5th record data. I have made all the box fields to be read only.
 
Thanks mike for the suggestion. i have not completly tested the suggestions provided. when i start to test the suggestions, another problem pop up. thats the reason why i have mixed up the questions. I will keep it in mind about the suggestions and will follow the same.
 
makdu,

No, you didn't modify the first record with the 5th. You recreate the cursor "myCursor" with your SQL select. Now the result only has the record where empid=lcEmpno. It didn't change the underlying employee table at all.

I assume you bound controls to "myCurssor", so now they show that new result. But that does not mean that the record they showed previously was edited. You simply totally replaced what the controls show.

Bye, Olaf.
 
By using
Code:
SELECT employee
LOCATE FOR EmpID = lclempno
ThisForm.refresh
I am able block the pop up and then modify the selected record only without affecting the values of first record
 
Well, then your controls are bound to the employee table directly. Selecting another record into a cursor won't change the record position in the employee table. Therefore you did edit the same record.

Now that you move in the employee table you edit that record, true.

You still need some caution: If the lcempno variable is from a textbox bound to the EmpID field, the user enters another empID number to change to that employee, then your code works, but you also changed the employee ID of the previously edited employee.

So what you need is an unbound textbox for such a filter or navigational field.

Bye, Olaf.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top