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

scatter memvar and missing m. fields

Status
Not open for further replies.

mallee

Programmer
Nov 7, 2000
116
Hello to All again.

Another wierd situation. I have a form in which I use a dbf as record source for a grid. I have a row of textboxes below the grid which are not assigned a control source.
In the first input texbox , I select the dbf and scatter memvar blank. All the fields are there as they should be. I progress through the textboxes and eventually do an Insert into dbf from memvar command. Not all of the fields are being updated. If I suspend execution amd ? m.whatever it may show one of the fields but get "Variable xxxx not found" message on the field next to it.
Has anyone ran into this behaviour before ?

Thanks for your ideas.

 
Are you declaring the variables before the form opens?

If you don't create the variables yourself, they will not be in scope. There are a few ways you can do it:

1) Declare all of the variables PUBLIC (bad idea for large projects)

2) Declare the variables PRIVATE in the code that calls the form (only works if the form is MODAL)

3) Assign each textbox's VALUE property to variables in the same procedure that does the GATHER

4) Create form properties for each textbox to be bound to and process them in the procedure that does GATHER

5) (my recommendation) Tie the boxes directly to the table and use Buffering.

Ian
 
No matter what method you do the Scatter to Memvars in, the variables are created locally (unless you previously declared them all PUBLIC or at least PRIVATE in the program that starts the form). One better way to do this, is to create a Form property (e.g. oMyRecord), then do a SCATTER NAME ThisForm.oMyRecord. Now you can use ThisForm.oMyRecord.field1, etc. as the controlsources for your textboxes. Note: If you set up the control source on you form (vs. setting them in your form Init() method), you need to add a SCATTER BLANK NAME ThisForm.oRecord in you Form's Load() method.

Rick
 
Thanks for the help. I used the scatter name/gather name and it works as expected.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top