Search:

NOT ABLE TOPLUG IN

Asked By: Kuhaylah    Date: Oct 27    Category: MS Office    Views: 1446

I am stuck with this thing in my project work , the
full coding really put me out of trouble.

There are two contents in table receiptno and deno
The user will ask in a textbox how much he require

We have to extract the deno,receiptno of the total

I have tried it with re.movenext,rs.moveprevious but
it seems
there is some lacuna which I AM NOT ABLE TOPLUG IN

Receipt No Deno SUM
R1 50 R1 220
R1 50 R2 220
R1 100 R3 500
R1 20 R4 300
R2 100 R5 150
R2 20 1390
R2 100
R3 500
R4 100
R4 100
R4 100
R5 50
R5 100
1390

CASE-I
Input 200

CASE-II 300
Input

CASE-III 1340
Input

Share:

This is the same query you already posted. I still don't understand - as
I said the last time - what all the 'CASE' business at the bottom means
- you're going to have to explain that. Also, to the right of the list,
you have totals. Are these calculated already?

Exactly what is the user  inputting and what do you want to return as a
result of it?

I just don't get this. Maybe I'm just having a dumb day. Can anyone else
in the group see what he's getting at?

I am regular watching this group from last 2-3 months
and it seems that you are the person who solves most
of the queries . I will once again try to put  my
problem.

A) I have got
Receipt No. Denomination
R1 50
R2 100
R3 100

I want that if option in a text box being given to
user
for feeding any no. say 200. The result should show
Receipt no Denomination
R2 100
R3 100

Basically it should first check :

If val(text1.text) < first field then
it should move to next field and add previous one
and goes in loop unless finds the sum of deno=text
field.

I am quite hopeful that you will solve my problem.

Do revert back if you still have any doubt about my
required output.

OK. I think I'm getting there, but I foresee a few problems. For
instance, in your example, how does the code reject the first item of
50? Until it looks further down the list, It can't tell that using this
won't give it an exact usage of the 200 amount, will it?

It will go to first record and as per the example if
it reads 50 which is less than 200 asked by user  it
moves on next record adds previous 50+new record 100
which makes it 150 (stores it in a variable).

*******every time it stores add value in variable
before moving on next record

It again checks the condition (with stored variable)
which is still < 200.

moves to next records add 100+150 (variable stored)
which makes 250 which is > 200 .
Now it search for 200 in reverse direction(ie. from
last to first record). As soon as it founds the right
combination it will show those records and leaves 50
out.

I know it is bit cumbersome but I am quite sure it is
workable .

I am clear about the logic but needs from scratch the
coding and I am sure I can get it from you.

OK. What if the user  enters 180????????

Just an observer of this problem. I would liken it to a check book with an
overdraft condition. If overdrawn by 500 what combination of checks issued
and outstanding would minimize the OD charges or the opposite condition what
combiniation would maximize it. It seems my bank uses a logic of
maximization!
I would summarize totals for each receipt first, then sort the receipts in
decending order. Cycle down the list with the first less than or equal to
OD. Repeat until total satisfied.

It will display a messgage saying that the amt asked
is not available.
Message like :

msgbox "The amt entered does not exist"

In that case, you're asking the code to do quite a complex job and it
seems like you'd have to do quite a few sums to determine there wasn't a
fit; there's lots of algorithms and evaluation here. I'd suggest you
hire a professional programmer; this type of 'best fit' algorithm can
take a pro days to get working.

Now I've said that, perhaps someone on the list will prove me wrong.

Didn't find what you were looking for? Find more on NOT ABLE TOPLUG IN Or get search suggestion and latest updates.