How many times a Qty could enter (Divided)

G

Guest

Hi all..I have this code to fill in a subform a field named[Qty] , this is
equal to: [List4] * [PLY]
-------------------------------------------------------
[ModANDSize SubForm]![Qty] = [List4] * [PLY]
DoCmd.GoToControl "ModANDSize SubForm"
DoCmd.GoToRecord , , acNewRec
List11.SetFocus
-------------------------------------------------------
but now the [Qty] has been divided in 4 fields like:
[10_Ply] , [5_Ply] ,[2_Ply] ,[1_Ply] ,

the objetive is that when I press the Button to move the values the qty from
[List4] need to be separated in these field like for example, if the [List4]
say 26 so the qty will be separated in:
[10_Ply] [5_Ply] [2_Ply] [1_Ply]
2 1 0 1 because 2*10+1*5+0*2+1*1= 26
another example:
if the [List4] say: 7 so the qty will be separated in:
[10_Ply] [5_Ply] [2_Ply] [1_Ply]
0 1 1 0 because 0*10+1*5+1*2+0*1= 7

could you help me on this..I will appreciate so much.

Thanks
 
G

Guest

Hi Lorenzo,

Here is a function that will get you started. You can likely call this
function in the After_Update event procedure for your combo box, or by
pressing the button as you mentioned. I think something like this will work,
assuming List4 is a listbox and you have the multiselect property set to No
for this control:

SplitNum(Me.List4)

****************************************
Function SplitNum(intListBoxNum As Integer)

Dim intTens As Integer
Dim intFives As Integer
Dim intTwos As Integer
Dim intOnes As Integer
Dim intRemainder As Integer

intTens = Int(intListBoxNum / 10)
intRemainder = intListBoxNum Mod 10

intFives = Int(intRemainder / 5)
intRemainder = intRemainder Mod 5

intTwos = Int(intRemainder / 2)
intRemainder = intRemainder Mod 2

intOnes = Int(intRemainder / 1)


Debug.Print "10's = " & intTens, vbTab, "5's = " & intFives, _
vbTab, "2's = " & intTwos, vbTab, "1's = " & intOnes

End Function

****************************************

A function only returns one value, so you'll need to come up with a method
of pushing the values from the function into the appropriate textboxes on
your subform. For the present time, I've just left a debug.print statement in
the function, so that you can see the results printed to the Immediate
window, which you can open by using Ctrl G (the control key and the G key
pressed at the same time). Here are the results for the two numbers you gave:

SplitNum(26)
10's = 2 5's = 1 2's = 0 1's = 1

SplitNum(7)
10's = 0 5's = 1 2's = 1 1's = 0


Tom

http://www.access.qbuilt.com/html/expert_contributors.html
http://www.access.qbuilt.com/html/search.html
__________________________________________

:

Hi all..I have this code to fill in a subform a field named[Qty] , this is
equal to: [List4] * [PLY]
-------------------------------------------------------
[ModANDSize SubForm]![Qty] = [List4] * [PLY]
DoCmd.GoToControl "ModANDSize SubForm"
DoCmd.GoToRecord , , acNewRec
List11.SetFocus
-------------------------------------------------------
but now the [Qty] has been divided in 4 fields like:
[10_Ply] , [5_Ply] ,[2_Ply] ,[1_Ply] ,

the objetive is that when I press the Button to move the values the qty from
[List4] need to be separated in these field like for example, if the [List4]
say 26 so the qty will be separated in:
[10_Ply] [5_Ply] [2_Ply] [1_Ply]
2 1 0 1 because 2*10+1*5+0*2+1*1= 26
another example:
if the [List4] say: 7 so the qty will be separated in:
[10_Ply] [5_Ply] [2_Ply] [1_Ply]
0 1 1 0 because 0*10+1*5+1*2+0*1= 7

could you help me on this..I will appreciate so much.

Thanks
 
G

Guest

Hi TOM....

this code work wonderfull,

Thank you for your support
--
Lorenzo Díaz
Cad Technician


Tom Wickerath said:
Hi Lorenzo,

Here is a function that will get you started. You can likely call this
function in the After_Update event procedure for your combo box, or by
pressing the button as you mentioned. I think something like this will work,
assuming List4 is a listbox and you have the multiselect property set to No
for this control:

SplitNum(Me.List4)

****************************************
Function SplitNum(intListBoxNum As Integer)

Dim intTens As Integer
Dim intFives As Integer
Dim intTwos As Integer
Dim intOnes As Integer
Dim intRemainder As Integer

intTens = Int(intListBoxNum / 10)
intRemainder = intListBoxNum Mod 10

intFives = Int(intRemainder / 5)
intRemainder = intRemainder Mod 5

intTwos = Int(intRemainder / 2)
intRemainder = intRemainder Mod 2

intOnes = Int(intRemainder / 1)


Debug.Print "10's = " & intTens, vbTab, "5's = " & intFives, _
vbTab, "2's = " & intTwos, vbTab, "1's = " & intOnes

End Function

****************************************

A function only returns one value, so you'll need to come up with a method
of pushing the values from the function into the appropriate textboxes on
your subform. For the present time, I've just left a debug.print statement in
the function, so that you can see the results printed to the Immediate
window, which you can open by using Ctrl G (the control key and the G key
pressed at the same time). Here are the results for the two numbers you gave:

SplitNum(26)
10's = 2 5's = 1 2's = 0 1's = 1

SplitNum(7)
10's = 0 5's = 1 2's = 1 1's = 0


Tom

http://www.access.qbuilt.com/html/expert_contributors.html
http://www.access.qbuilt.com/html/search.html
__________________________________________

:

Hi all..I have this code to fill in a subform a field named[Qty] , this is
equal to: [List4] * [PLY]
-------------------------------------------------------
[ModANDSize SubForm]![Qty] = [List4] * [PLY]
DoCmd.GoToControl "ModANDSize SubForm"
DoCmd.GoToRecord , , acNewRec
List11.SetFocus
-------------------------------------------------------
but now the [Qty] has been divided in 4 fields like:
[10_Ply] , [5_Ply] ,[2_Ply] ,[1_Ply] ,

the objetive is that when I press the Button to move the values the qty from
[List4] need to be separated in these field like for example, if the [List4]
say 26 so the qty will be separated in:
[10_Ply] [5_Ply] [2_Ply] [1_Ply]
2 1 0 1 because 2*10+1*5+0*2+1*1= 26
another example:
if the [List4] say: 7 so the qty will be separated in:
[10_Ply] [5_Ply] [2_Ply] [1_Ply]
0 1 1 0 because 0*10+1*5+1*2+0*1= 7

could you help me on this..I will appreciate so much.

Thanks
 
G

Guest

Hi Lorenzo,

I'm glad to hear that. You're very welcome.


Tom

http://www.access.qbuilt.com/html/expert_contributors.html
http://www.access.qbuilt.com/html/search.html
__________________________________________

ldiaz said:
Hi TOM....

this code work wonderfull,

Thank you for your support
--
Lorenzo Díaz
Cad Technician


Tom Wickerath said:
Hi Lorenzo,

Here is a function that will get you started. You can likely call this
function in the After_Update event procedure for your combo box, or by
pressing the button as you mentioned. I think something like this will work,
assuming List4 is a listbox and you have the multiselect property set to No
for this control:

SplitNum(Me.List4)

****************************************
Function SplitNum(intListBoxNum As Integer)

Dim intTens As Integer
Dim intFives As Integer
Dim intTwos As Integer
Dim intOnes As Integer
Dim intRemainder As Integer

intTens = Int(intListBoxNum / 10)
intRemainder = intListBoxNum Mod 10

intFives = Int(intRemainder / 5)
intRemainder = intRemainder Mod 5

intTwos = Int(intRemainder / 2)
intRemainder = intRemainder Mod 2

intOnes = Int(intRemainder / 1)


Debug.Print "10's = " & intTens, vbTab, "5's = " & intFives, _
vbTab, "2's = " & intTwos, vbTab, "1's = " & intOnes

End Function

****************************************

A function only returns one value, so you'll need to come up with a method
of pushing the values from the function into the appropriate textboxes on
your subform. For the present time, I've just left a debug.print statement in
the function, so that you can see the results printed to the Immediate
window, which you can open by using Ctrl G (the control key and the G key
pressed at the same time). Here are the results for the two numbers you gave:

SplitNum(26)
10's = 2 5's = 1 2's = 0 1's = 1

SplitNum(7)
10's = 0 5's = 1 2's = 1 1's = 0


Tom

http://www.access.qbuilt.com/html/expert_contributors.html
http://www.access.qbuilt.com/html/search.html
__________________________________________

:

Hi all..I have this code to fill in a subform a field named[Qty] , this is
equal to: [List4] * [PLY]
-------------------------------------------------------
[ModANDSize SubForm]![Qty] = [List4] * [PLY]
DoCmd.GoToControl "ModANDSize SubForm"
DoCmd.GoToRecord , , acNewRec
List11.SetFocus
-------------------------------------------------------
but now the [Qty] has been divided in 4 fields like:
[10_Ply] , [5_Ply] ,[2_Ply] ,[1_Ply] ,

the objetive is that when I press the Button to move the values the qty from
[List4] need to be separated in these field like for example, if the [List4]
say 26 so the qty will be separated in:
[10_Ply] [5_Ply] [2_Ply] [1_Ply]
2 1 0 1 because 2*10+1*5+0*2+1*1= 26
another example:
if the [List4] say: 7 so the qty will be separated in:
[10_Ply] [5_Ply] [2_Ply] [1_Ply]
0 1 1 0 because 0*10+1*5+1*2+0*1= 7

could you help me on this..I will appreciate so much.

Thanks
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top