Normal Topic [solved] need help with subform in V2 (Read 791 times)
wase
Junior Member
**
Offline


Always looking for a good
code

Posts: 57
Location: Austria
Joined: Jun 22nd, 2004
[solved] need help with subform in V2
Dec 18th, 2007 at 1:27am
Print Post Print Post  
change from version 1 to version 2 using FormCommit() solved the problem

when i call the @formresultsettotal in a new window (no data insertet) the result is 0
so i inserted the code if vn1 = 0...
but when i use @formnewrecord("Artikelliste") then vn2 also gets to 0 so there is no chance to get a higer number (new records to post in)! also @formresultsettotal is 0 until i switch to the subform and back then the @formresultsettotal changes into 1

Code
Select All
			vn1 = @formresultsettotal("Artikelliste")
			if vn1 = 0 then
			{
				vn1 = 1
			}
			vn2 = @tn(@formfieldvalue("Artikelliste", "Menge", vn1))

			if vn2 <> 0 then
			{
				 vn2 = @formnewrecord("Artikelliste")
				 vn1 = vn2
			}
 

« Last Edit: Dec 22nd, 2007 at 12:38am by wase »  
Back to top
ICQ ICQ  
IP Logged
 
wase
Junior Member
**
Offline


Always looking for a good
code

Posts: 57
Location: Austria
Joined: Jun 22nd, 2004
Re: need help with subform in V2
Reply #1 - Dec 18th, 2007 at 2:05am
Print Post Print Post  
i can't solve it. formthrowfocus does not work its always a mess
i built a button with a writeln(@formresultstetotal())
when i press this one and add a record it works but when i add a record without the button it does not
(the first record gets overwriten)
in V1 this code does work perfekt

next problem: when the save record command is used (selecttreeitem) the curser jumps to the element counter and the the programing is stoped (also worked in V1)
  
Back to top
ICQ ICQ  
IP Logged
 
wase
Junior Member
**
Offline


Always looking for a good
code

Posts: 57
Location: Austria
Joined: Jun 22nd, 2004
Re: need help with subform in V2
Reply #2 - Dec 18th, 2007 at 3:16am
Print Post Print Post  
i give a better example:

a database with 2 fields (test1, test2) and a subform with 1 field(text1)

the programming for test1:
Code
Select All
var vn1 as int
var i as int
var input as string

subroutine writesub()

vn1=@formresultsettotal("sub")
if vn1 = 0 then
vn1 = 1

input = test1

i = @formnewrecord("sub")
formfieldvalue("sub","text1",vn1,input)


end subroutine

writesub()
test1="" 



programming for test2:
Code
Select All
goto test1 



subform has no programming

there the data is always writen in the first line of the subform!! why??? the formresultsettotal shuld give back a higher number to write in!
  
Back to top
ICQ ICQ  
IP Logged
 
Carl Underwood
Senior Member
Members
*****
Offline



Posts: 1351
Location: New Hampshire
Joined: Mar 11th, 2003
Re: need help with subform in V2
Reply #3 - Dec 18th, 2007 at 5:50am
Print Post Print Post  
Quote:
the data is always writen in the first line of the subform!! why???

Because that is where you are telling it to write it. Wink

You assigned the value "1" to vn1, then you used vn1 to tell Sesame which line to place the data in.
formfieldvalue("sub","text1",vn1,input)

This line of code will assign the line number of the new record to "i".
i = @formnewrecord("sub")

So, if you want to add a new record to the subform, you don't need to use @FormResultSetTotal, you only need to use @FormNewRecord, and it will return the number of the new record.

Try this instead.
i = @formnewrecord("sub")
formfieldvalue("sub","text1",i,input)
  


Carl Underwood
CDU Computer Consulting LLC
Epsom, New Hampshire
Back to top
IP Logged
 
wase
Junior Member
**
Offline


Always looking for a good
code

Posts: 57
Location: Austria
Joined: Jun 22nd, 2004
Re: need help with subform in V2
Reply #4 - Dec 18th, 2007 at 11:52am
Print Post Print Post  
but when i need to know how many records are in the subform. the program i posted is a simple test application the real one is a bit biger and there i need to know how many recrods are in the subform

i allready used a formthrowfocus() to change to the sub and in the sub a formthrowfocus() to go back.
then the @formresultsettotal is ok but this was just in the test application in the real one this wont work.

is there a simple way to get the @formresultsettotal() to work?
  
Back to top
ICQ ICQ  
IP Logged
 
Ray the Reaper
Global Moderator
Members
Lantica Support
*****
Offline


The One & The Only

Posts: 2482
Joined: Aug 20th, 2003
Re: need help with subform in V2
Reply #5 - Dec 18th, 2007 at 2:28pm
Print Post Print Post  
What version of 2.X are you running?


The code below when added to a command button on the parent form of the Countries sample application works perfectly in 2.0.4. There is no need to use ThrowFocus to the sub or anything like that.

Code
Select All
Var vRecNum as Int
Var vRecCnt as Int

	vRecCnt = @FormResultSetTotal("Cities")
	If vRecCnt = 0 Then
	{
		//No records in the sub have been commited yet so use the first record.
		vRecNum = 1
	}
	Else
	{
		//There are already Records in the sub so let's create a new one.
		vRecNum = @FormNewRecord("Cities")
	}

	FormFieldValue("Cities", "Population", vRecNum, Population)
	FormCommit("Cities") 



-Ray
  

Raymond Yoxall Consulting
ray.yoxall@gmail.com
ryoxall@lantica.com
Sesame Applications, Design and Support
Back to top
IP Logged
 
Ray the Reaper
Global Moderator
Members
Lantica Support
*****
Offline


The One & The Only

Posts: 2482
Joined: Aug 20th, 2003
Re: need help with subform in V2
Reply #6 - Dec 18th, 2007 at 2:38pm
Print Post Print Post  
Quote:
next problem: when the save record command is used (selecttreeitem) the curser jumps to the element counter and the the programing is stoped (also worked in V1)


@SelectTreeItem() does not prevent programming from running nor does it stop the current event while it is running. It does move the cursor up to the Record Counter however same as the Menu Tree Option does.

If you wish to save the record without the cursor moving to the Record Counter then use FormCommit(). The order you will want to do the commits in is the subs first and then the parent form.

Code
Select All
FormCommit("Sub")
FormCommit("Parent") 



-Ray
  

Raymond Yoxall Consulting
ray.yoxall@gmail.com
ryoxall@lantica.com
Sesame Applications, Design and Support
Back to top
IP Logged
 
wase
Junior Member
**
Offline


Always looking for a good
code

Posts: 57
Location: Austria
Joined: Jun 22nd, 2004
Re: need help with subform in V2
Reply #7 - Dec 18th, 2007 at 3:21pm
Print Post Print Post  
thanks ray i will try it this way
  
Back to top
ICQ ICQ  
IP Logged