I am stuck with DAO need help please 
Author Message
 I am stuck with DAO need help please

Dear All

I am a bit new to DAO and I am trying to figure out the following problem:

table (suniltest)

Reference                  F0F8TA             Movement
1                                  200                    +200
2                                  400                    +200
3                                  100                     -300

What I am trying to achieve is to get the Movement figure but I am having no
luck, I have tried the following codes with no avail, I am able to get the
result in a string with the second code but what I really need some thing
more like the first code:

My first attempt was the following:

Function Move(Field As Variant) As Variant

Dim db As Database
Dim rst As Recordset
Dim varValue1 As Variant, varValue2 As Variant, calc As Variant
Set db = CurrentDb
Set rst = db.OpenRecordset("suniltest", dbOpenDynaset)

varValue1 = Field
rst.MoveNext
varValue2 = rst!F0F8TA

calc = varValue2 - varValue1

Move = calc

End Function

Second Attempt:

Function Move() As Variant
Dim db As Database
Dim rst As Recordset
Dim varValue1 As Variant, varValue2 As Variant, calc As Variant
Dim c As Integer, result As String
Set db = CurrentDb
Set rst = db.OpenRecordset("suniltest", dbOpenDynaset)
c = 1
       Do
                If c = 1 Then
                        rst.MovePrevious
                            If rst.BOF Then
                            rst.MoveNext
                            calc = rst!F0F8TA
                            c = c + 1
                            End If
                            result = calc

                ElseIf c > 1 Then
                    Do Until rst.EOF
                    varValue1 = rst!F0F8TA
                    rst.MoveNext
                    If rst.EOF Then
                    Move = result
                    Exit Function

                    Else
                    varValue2 = rst!F0F8TA
                    End If
                    calc = Str(varValue2 - varValue1)
                    result = result & "," & calc
                    Loop
                End If
       Loop
End Function

Could some give me the correct code as I have tryed so many different ways
but it does not work and I am now close to tears. ;-|

Kindest Regards

Sunil



Sun, 13 Apr 2003 03:00:00 GMT  
 I am stuck with DAO need help please
On Wed, 25 Oct 2000 20:41:31 +0100, "maveric_32n"

Quote:

>Dear All

>I am a bit new to DAO and I am trying to figure out the following problem:

>table (suniltest)

>Reference                  F0F8TA             Movement
>1                                  200                    +200
>2                                  400                    +200
>3                                  100                     -300

>What I am trying to achieve is to get the Movement figure but I am having no
>luck, I have tried the following codes with no avail, I am able to get the
>result in a string with the second code but what I really need some thing
>more like the first code:

>My first attempt was the following:

>Function Move(Field As Variant) As Variant

>Dim db As Database
>Dim rst As Recordset
>Dim varValue1 As Variant, varValue2 As Variant, calc As Variant
>Set db = CurrentDb
>Set rst = db.OpenRecordset("suniltest", dbOpenDynaset)

rst.movefirst
varValue1 = rst!F0F8TA
rst.movenext

do while not rst.eof
rst.edit
rst!movement = rst!F0F8TA  -  varValue1
rst.update
rst.movenext
loop



Sun, 13 Apr 2003 03:00:00 GMT  
 I am stuck with DAO need help please
Thank you very much that work a treat, but the only problem is that is did
not give me a figure for the first one i.e. the reference1 movement.

Kindest Regards

Sunil

Quote:
>>Dear All

>>I am a bit new to DAO and I am trying to figure out the following problem:

>>table (suniltest)

>>Reference                  F0F8TA             Movement
>>1                                  200                    +200
>>2                                  400                    +200
>>3                                  100                     -300

>>What I am trying to achieve is to get the Movement figure but I am having
no
>>luck, I have tried the following codes with no avail, I am able to get the
>>result in a string with the second code but what I really need some thing
>>more like the first code:

>>My first attempt was the following:

>>Function Move(Field As Variant) As Variant

>>Dim db As Database
>>Dim rst As Recordset
>>Dim varValue1 As Variant, varValue2 As Variant, calc As Variant
>>Set db = CurrentDb
>>Set rst = db.OpenRecordset("suniltest", dbOpenDynaset)

>rst.movefirst
>varValue1 = rst!F0F8TA
>rst.movenext

>do while not rst.eof
>rst.edit
>rst!movement = rst!F0F8TA  -  varValue1
>rst.update
>rst.movenext
>loop



Sun, 13 Apr 2003 03:00:00 GMT  
 I am stuck with DAO need help please
Actually I have been studying the result and found that the code is great be
does not do what I  wanted it do to.

If you look more closely the movement must be as a the difference between
record 0 and 1(+200), 1 and 2(+200), 2 and 3(-300):

Reference                  F0F8TA             Movement
1                                  200                    +200
2                                  400                    +200
3                                  100                     -300

the code given gives the difference between 1 and 2, 1 and 3

sorry about this one guys/ girls, can any one help???

Kindest Regards

Sunil

Quote:

>Thank you very much that work a treat, but the only problem is that is did
>not give me a figure for the first one i.e. the reference1 movement.

>Kindest Regards

>Sunil

>>>Dear All

>>>I am a bit new to DAO and I am trying to figure out the following
problem:

>>>table (suniltest)

>>>Reference                  F0F8TA             Movement
>>>1                                  200                    +200
>>>2                                  400                    +200
>>>3                                  100                     -300

>>>What I am trying to achieve is to get the Movement figure but I am having
>no
>>>luck, I have tried the following codes with no avail, I am able to get
the
>>>result in a string with the second code but what I really need some thing
>>>more like the first code:

>>>My first attempt was the following:

>>>Function Move(Field As Variant) As Variant

>>>Dim db As Database
>>>Dim rst As Recordset
>>>Dim varValue1 As Variant, varValue2 As Variant, calc As Variant
>>>Set db = CurrentDb
>>>Set rst = db.OpenRecordset("suniltest", dbOpenDynaset)

>>rst.movefirst
>>varValue1 = rst!F0F8TA
>>rst.movenext

>>do while not rst.eof
>>rst.edit
>>rst!movement = rst!F0F8TA  -  varValue1
>>rst.update
>>rst.movenext
>>loop



Sun, 13 Apr 2003 03:00:00 GMT  
 I am stuck with DAO need help please
On Wed, 25 Oct 2000 21:03:20 +0100, "maveric_32n"

Quote:

>Thank you very much that work a treat, but the only problem is that is did
>not give me a figure for the first one i.e. the reference1 movement.

>>>Function Move(Field As Variant) As Variant

>>>Dim db As Database
>>>Dim rst As Recordset
>>>Dim varValue1 As Variant, varValue2 As Variant, calc As Variant
>>>Set db = CurrentDb
>>>Set rst = db.OpenRecordset("suniltest", dbOpenDynaset)

>>rst.movefirst

rst.edit
rst!movement=rst!F0F8TA
rst.update
Quote:
>>varValue1 = rst!F0F8TA
>>rst.movenext

>>do while not rst.eof
>>rst.edit
>>rst!movement = rst!F0F8TA  -  varValue1
>>rst.update
>>rst.movenext
>>loop



Sun, 13 Apr 2003 03:00:00 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. error 91 please help as i am stuck

2. Please Help. I am stuck

3. I am stuck...in need urgent help!!!!!

4. Help with dbgrid....I am stuck

5. Help: i am stuck

6. Help Guys I am Stuck Real Bad

7. I am alway with my DOS please I need your help

8. Need Am I Online Function, Please Help

9. PLEASE HELP, PLEASE HELP, PLEASE HELP, PLEASE HELP, PLEASE HELP, PLEASE HELP, PLEASE HELP,

10. Please tell me what I am doing wrong - DAO parameter Append Query :(

11. DAO 3.6 help needed please

12. Please, please help, I am desperated...:(

 

 
Powered by phpBB® Forum Software