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

My best shot won't work VBA for access code

Status
Not open for further replies.

RBE

Programmer
May 25, 2000
72
US
This code seem to have several problems, the most prominate though, is that It only pulls back the frist record and will not continue to loop through the rest of the records pulled from the qurey. What I am trying to do is pull orders that a customer's check should be applied to. I was not able to get a clear answer on how to do this so I took a shot at it myself (6 or 7 times). This actually brought back something other then an error. Although it is only bringing back the first value in [qryorders] and nothing else.
My best shot

'first set of critera'
If (Reports![rptdglrpt].[running sum] < Forms![frmDGLRPT].[check1]) Then
Reports![rptdglrpt].[order_amt]'order_amt is an unbound field on the report'= Reports![rptdglrpt].[qryorders]
'this should pull back a single value according to the above critera text80 control source is an'order $ amount field from the table''
'second set of critera'
ElseIf Reports![rptdglrpt].[running sum] > Forms![frmDGLRPT].[check1] Then
'this should populate order_amt with the remainder of the check'
Reports![rptdglrpt].[order_amt] = Reports![rptdglrpt].[running sum] - Forms![frmDGLRPT].[check1]
End If
 
John,

I wish you the best in helping RBE. &quot;He&quot; has posted variations on this question about 6 times in the last few days in Ms & VB Forums. &quot;He&quot; appears to not really understand either the problem or the responses. My 'understanding' is that he is simplying to apply a payment to an account in the same sense as a general ledger accounting app. But there is some confusion. He does not appear to maintain the payment applied to a debit entry. He does not appear to maintain the PaymentID (check #) with the ammount applied (also not maintained) ...

Do a search on his handle in MS Access and VB. Read the already posted questions and responses. At least you will have a more complete picture of the situation.

MichaelRed
mred@att.net

There is never time to do it right but there is always time to do it over
 
I am sorry for being a pain. I will not post on this subject again. And it is &quot;her&quot;, working on a report for &quot;her&quot; boss. I was just giving the information I have to work with and manipulate. Sorry again.
RBE
 
what exactly are you trying to do?? Or, rather, what is this code supposed to do? That's gotta be the most jumbled piece of code i've ever seen :p Tell me what you want the program to do, and what it's doing instead...i'll see if I can help :p

Rob
 
one thought here might be that &quot;IF&quot; is not what I'd consider a &quot;loop&quot;. Also, I don't see that you incremented any of your variables...How is the code supposed to check multiple parts of an array, if you only have it pointing to one? See if this helps...

--------------------------------------------
myLoop = 0

do while myLoop < num_OfRecords
form.print ThisRecord(recordID, myLoop)
myLoop = myLoop + 1
loop
--------------------------------------------

or...

--------------------------------------------
for myLoop = 0 to num_OfRecords
form.print ThisRecord(recordID, myLoop)
next myLoop
--------------------------------------------

good luck ;)

Rob
 
RBE,

I do not mean to discourage you from requesting help. I was attempting to paee along additional information which might help others in assisting you. I responded to one of your other posts, and - if I rember correctly - you did not reply with additional information or comment on the advice given/question(s) asked. John Yingling is a highly respected member of these forums and may be able to give you much more assistance than I have. I was simply letting him know ther was additional information on your subject in other posts.

Sorry if I inadvertantly bruised &quot;her&quot; feelings. Not my intent at all.

MichaelRed
mred@att.net

There is never time to do it right but there is always time to do it over
 
I am going to make one more atempt at explaining this. What I am trying to do is make a deferred gain/loss report. I have put this same question in several different formats trying to make it easier to understand. I have a form, on the form I input into three fields as follows. There are a total of 6 product codes each code has a group of fields (ie product code, gallons received,market cost)
field 1 &quot;product code&quot;
field 2 &quot;gallons received&quot; off site inventory
field 3 &quot;market cost&quot; that's it
I have a query the query pulls
&quot;date received&quot; decending order
&quot;gallons received&quot; Inventory
&quot;Inventory cost&quot;
&quot;product code&quot;
&quot;ticket number&quot; Primary key
other assorted information to calculate Gain/loss but not used to calculate gallons
Here is what I need the code be it sql or vba to do:
Loop through the query results that have been sorted by date in decending order and pull (starting with the latest date i.e. today) ticket numbers that are going to add up (gallons received) to the figure entered in the form field &quot;gallons received&quot;. These two will rarely = if ever at all so what I need it to do in the case it does not equal is bring back the next &quot;ticket number&quot;s gallons received and temperally change that figure to the remaining difference between the forms balance and the reports balance. None of this should effect the table in any way. None of the reported information will be stored in the DB only the original &quot;working&quot; information is stored. This is as clear as I can get. I take no offence to pointing out my lacks. In fact I appreicate it. I hope this helps. If any one can find it at this point. Thank you guys for all your help. It has helped me more than you can imagin. thanks again. RMB
 
If I am understanding it correctly you can do all of that with a correctly constructed query in access. and a little code in an unbound box to sum up the difference.

However if you want to do it all in code I will spare some brain cells towards it during this weekend
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top