By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,466 Members | 2,523 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,466 IT Pros & Developers. It's quick & easy.

Why is my calculation coming out as 0

P: n/a
I have the following code - but the calculation is coming out to be 0
rather than the percentage.

Any ideas?

Thanks

Function GetAdoptionRate() As Integer
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim strSQL As String
Dim datStart, datEnd, d1 As Date
Dim intTelemedReceives As Integer
Dim intMUApps As Integer
Dim intAdoptionRate As Double

Set db = CurrentDb()

Set rs = db.OpenRecordset("SELECT * FROM qryTelemedReceives",
dbOpenDynaset)
With rs
.MoveFirst
intTelemedReceives = rs("CountOfPolicyNumber")
End With

Set rs = db.OpenRecordset("SELECT * FROM
qryMedicallyUnderwrittenReceives", dbOpenDynaset)
With rs
.MoveFirst
intMUApps = rs("CountOfPolicyNumber")
End With
Debug.Print Format(intTelemedReceives \ intMUApps, "Percent") <-------
returns 0

Set db = Nothing
Set rs = Nothing
End Function

FYI intMUApps = 24,000 and intTelemedReceives = 4,000

TIA

Jan 2 '07 #1
Share this Question
Share on Google+
2 Replies


P: n/a
"BerkshireGuy" <be*************************@yahoo.comwrote in message
news:11**********************@48g2000cwx.googlegro ups.com...
>I have the following code - but the calculation is coming out to be 0
rather than the percentage.

Any ideas?

Thanks

Function GetAdoptionRate() As Integer
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim strSQL As String
Dim datStart, datEnd, d1 As Date
The line above will make datStart and datEnd as Variants. Only d1 will be a
Date. I assume that this is not what you want. It is not related to your
problem
Debug.Print Format(intTelemedReceives \ intMUApps, "Percent") <-------
returns 0
The back-slash \ operator performs Integer Division where the result has all
fractional portions truncated. I suspect that if you used a forward slash /
that you would get what you want.

--
Rick Brandt, Microsoft Access MVP
Email (as appropriate) to...
RBrandt at Hunter dot com
Jan 2 '07 #2

P: n/a
Rick:

Thank you! I would have NEVER picked up on that - especially a day
after New Years! :)

Thanks again,
Brian

Rick Brandt wrote:
"BerkshireGuy" <be*************************@yahoo.comwrote in message
news:11**********************@48g2000cwx.googlegro ups.com...
I have the following code - but the calculation is coming out to be 0
rather than the percentage.

Any ideas?

Thanks

Function GetAdoptionRate() As Integer
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim strSQL As String
Dim datStart, datEnd, d1 As Date

The line above will make datStart and datEnd as Variants. Only d1 will be a
Date. I assume that this is not what you want. It is not related to your
problem
Debug.Print Format(intTelemedReceives \ intMUApps, "Percent") <-------
returns 0

The back-slash \ operator performs Integer Division where the result has all
fractional portions truncated. I suspect that if you used a forward slash /
that you would get what you want.

--
Rick Brandt, Microsoft Access MVP
Email (as appropriate) to...
RBrandt at Hunter dot com
Jan 2 '07 #3

This discussion thread is closed

Replies have been disabled for this discussion.