Error 3061expected too few parameters, Expected 1 (1 Viewer)

nashfaq

Registered User.
Local time
Today, 04:48
Joined
Oct 17, 2018
Messages
28
Dear Friends

i have created a function that will populate the values in a report from a query

if i set month value in query as "JULY" then the report shows all the values and below function runs perfectly. as shown below
2.JPG

the report shows all the values...without error


Then added a form with combo to select the month from the list as shown below

1.JPG

and Open the report, it gives error on the same function

Below is the code, kindly help me why this is happening and how could i get solve that issue

Function MonthTranscation(BankName As String, FieldNo As Integer) As Long



Dim Name_Field_DB, Name_Field As String
Dim Amount_Field As String
Dim TotalNo_Field, Number_Field As Integer

Dim RCnt As Long
Dim Msg As String




Set db = CurrentDb
Set rs = db.OpenRecordset("SELECT * FROM [QryMonthlyReport_Final] WHERE [QryMonthlyReport_Final].[ID_Jamat] = '" & BankName & "' ")




If rs.BOF = True Then
Exit Function
Else


rs.MoveFirst
rs.MoveLast
TotalNo_Field = rs.Fields.Count 'To Count No of Fields
RCnt = rs.RecordCount
Number_Field = 0
rs.MoveFirst


' Do

Name_Field_DB = rs.Fields(FieldNo).Name ' Finding the Name of The field Debit
' Debug.Print Name_Field_DB


MonthTranscation= rs.Fields(Name_Field_DB).Value


End If

Set rs = Nothing
Set db = Nothing
End Function
 

Gasman

Enthusiastic Amateur
Local time
Today, 00:48
Joined
Sep 21, 2011
Messages
14,048
A. Is the form open?
B. You do not have ID_Jamat in the query?
C. You are not DIMming your variables correctly. You need to specify type separately for each variable.?

C is not going to affect this issue, but just so you are aware.
 

nashfaq

Registered User.
Local time
Today, 04:48
Joined
Oct 17, 2018
Messages
28
Hi Gasman

A. Yes Form remains Open
B ID_Jamat is Also is in the query as shown below for both querries

C. DIMming . BankName is an String as this is a Name, and FiledNo as Integer as value of the field
if there is something wrong please help me which one is wrongly defined.

Please note that, every thing works fine, if i type JULY, if a form is used then give error

regards


1.JPG


2.JPG
 

Gasman

Enthusiastic Amateur
Local time
Today, 00:48
Joined
Sep 21, 2011
Messages
14,048
This is not going to fix your problem, but you should be dimming like
Code:
Dim Name_Field_DB as String, Name_Field As String
Dim Amount_Field As String
Dim TotalNo_Field as Integer, Number_Field As Integer
so it might be the old chestnut where you have to Eval the parameter.?

First check Similar threads below, then search use theDBGuy as poster for the error. He has answered quite a few of these, so knows them well. :cool:
 

nashfaq

Registered User.
Local time
Today, 04:48
Joined
Oct 17, 2018
Messages
28
Hi

I made the changes in DIMming the variables
Dim Name_Field_DB as String
Dim Name_Field As String
Dim Amount_Field As String
Dim TotalNo_Field as Integer,
Dim Number_Field As Integer
But still have same error

I also search the threats but didn't find the solution.


Please advise further...
 

theDBguy

I’m here to help
Staff member
Local time
Yesterday, 17:48
Joined
Oct 29, 2018
Messages
21,358
Please help how to use that functions.

I am not so expert in programmings..

Thanks..
Copy and paste the generic DAO function into a module and change one line in your code.

Code:
Set rs = fDAOGenericRst("SELECT...
 

nashfaq

Registered User.
Local time
Today, 04:48
Joined
Oct 17, 2018
Messages
28
Hi DBGuys

Thanks a lot for help, now its working perfectly.

Regards
Nasir
 

theDBguy

I’m here to help
Staff member
Local time
Yesterday, 17:48
Joined
Oct 29, 2018
Messages
21,358
Hi DBGuys

Thanks a lot for help, now its working perfectly.

Regards
Nasir
Congratulations! Glad to hear you got it sorted out. Good luck with your project.
 

Users who are viewing this thread

Top Bottom