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

Too few Parameters error in Function

Status
Not open for further replies.

psperry2

Programmer
Nov 7, 2007
141
US
This Function gets an error on the first set rst= line. it is called from a query. I don't see anything requiring parameters here.

Function Completd(PersonID As Variant) As Variant
Dim Numb_Completed As Integer
Dim Total_Steps As Integer
Dim Pct_Completed As Variant
Dim mydb As Database
Dim rst As Recordset

Set mydb = CurrentDb

Set rst = mydb.OpenRecordset("Select count(*) as Numb_Completed FROM tblPersons_Steps WHERE TblPersons_Steps.InvID = " & PersonID & " AND TblPersons_Steps.Status IN ('N/A', 'Passed', 'Received', 'Dropped')")
Numb_Completed = rst!Numb_Completed

Set rst = mydb.OpenRecordset("Select count(*) as Total_Steps FROM tblPersons_Steps WHERE TblPersons_Steps.ISInvID =" & PersonID)
Total_Steps = rst!Total_Steps

If Total_Steps > 0 Then
Pct_Completed = (Numb_Completed / Total_Steps) * 100
Else
Pct_Completed = 0
End If

Completd = Pct_Completed
End Function
 
Ok I found the problem. What was displayed in the field from opening the table was not the actual value. The displayed value was a value from another table. Once I corrected for that, it worked.

I verified that the calculations are correct. However in the report, I am having trouble printing the number. If the calculated percentage in the query is 8.08080808 percent I am seeing 8080808 on the report. The decimal point is missing. I tried setting the format of that report field to '##0.00'. This didn't help.
 
The General Number and Fixed formats are not working as expected.
 
The General Number and Fixed formats are not working as expected.

Which means what exactly?

What were you expecting and what is happening instead?
 
the number displayed in the query view is 8.08080808

but ont the report there is no decimal point, I see
8080808
 
After widening the textbox, the decimal point was finally displayed. I am not sure what to do to get the number displayed in a decent format.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top