Welcome To The Home Of The Visual FoxPro Experts  
home. signup. forum. archives. search. google. articles. downloads. faq. members. weblogs. file info. rss.
 From: tushar Kanvinde
  Where is tushar Kanvinde?
 Kolhapur, Maharastra
 India
 tushar Kanvinde
 To: Joseph G. Njoroge
  Where is Joseph G. Njoroge?
 Nairobi
 Kenya
 Joseph G. Njoroge
 Tags
Subject: RE: Grid on a Form
Thread ID: 143618 Message ID: 143620 # Views: 1 # Ratings: 0
Version: Visual FoxPro 9 Category: Forms
Date: Thursday, August 30, 2007 11:39:48 AM         
   


> Dear Experts,
> Am trying to view customers invoices whereby am selecting/typing required customer account on a combobox.Then setting filters to transaction file on the value returned from the combobox. I want the filtered records to populate the grid.
> attached find the form layout and also the on valid code am using. Please assist.
>
>
>
>
IF thisform.cboaccno.Value<>' ' THEN 
> 	thisform.waccname=customer.accname
> 	thisform.wpc=customer.proeng
> 	thisform.wdescript=customer.descript
> 	thisform.wcontract=customer.contract
> 		
> 	thisform.txtAccname.Value=thisform.waccname
> 	thisform.txtproeng.Value=thisform.wpc
> 	thisform.txtdescript.Value=thisform.wdescript
> 	thisform.txtcontract.Value=thisform.wcontract
> 	SELECT custtran
> 	SET FILTER TO ALLTRIM(accno)=ALLTRIM(thisform.wcboaccno)
> 	GO TOP 
> 	CREATE CURSOR custdetails (accno character(10),reference character(10),;
> 		invdate DATE, invoiced N(12,2),remark memo)
> 	SELECT custdetails	
> 	APPEND FROM custtran	
> ELSE
>  	thisform.txtaccname.Value=' '
>  	thisform.txtdescript.Value=' '
>  	thisform.txtProeng.Value=''
>  	thisform.txtcontract.Value=0.00
> ENDIF 

>
> Best Regards,
> Joseph G. Njoroge


Joseph

>SET FILTER TO ALLTRIM(accno)=ALLTRIM(thisform.wcboaccno)

Never set a filter on a form property. If you ever call an outside prg from the form, the property will go out of scope and you will get an error. Instead do something like

local lnwcboaccno
lnwcboaccno=allt(thisform.wcboaccno)
SET FILTER TO ALLTRIM(accno)="&lnwcboaccno"

Since the filter is now on a literal it cannot go out of scope.

If your custtran table can be set to be ordered by accno then your task becomes very easy

In the dataenvironment, set a relation between the client and custtran and make custtran the recordsource of the grid. That's all you need to do.

If you want the data to be date wise then create a tag in custtran on accno+dtos(date) and set the relation to this tag.

When you are comparing 2 codes, never use alltrim() and always use == instead of =.

Regards
Tushar

ENTIRE THREAD

Grid on a Form Posted by Joseph G. Njoroge @ 8/30/2007 11:06:10 AM
RE: Grid on a Form Posted by tushar @ 8/30/2007 11:39:48 AM
RE: Grid on a Form Posted by Cetin Basoz @ 8/30/2007 2:01:40 PM
RE: Grid on a Form Posted by Joseph G. Njoroge @ 9/7/2007 10:44:22 AM
RE: Grid on a Form Posted by Cetin Basoz @ 9/7/2007 2:43:05 PM
RE: Grid on a Form Posted by Joseph G. Njoroge @ 9/8/2007 8:07:16 AM
RE: Grid on a Form Posted by Cetin Basoz @ 9/8/2007 8:22:15 AM
RE: Grid on a Form Posted by tushar @ 9/8/2007 8:27:27 AM
RE: Grid on a Form Posted by Cetin Basoz @ 9/8/2007 8:42:26 AM
RE: Grid on a Form Posted by Joseph G. Njoroge @ 9/8/2007 8:55:26 AM
RE: Grid on a Form Posted by Joseph G. Njoroge @ 9/10/2007 10:16:33 AM
RE: Grid on a Form Posted by Cetin Basoz @ 9/10/2007 1:53:44 PM