Mismatch Error 13 with dates

VSolano

Registered User.
Local time
Today, 01:54
Joined
Feb 21, 2017
Messages
92
Can someone please check this function and give me some advice regarding fixing this mismatch.


Public Function MonthlyAmt(FLNo As Integer) As Currency

Dim MthDate As Date
Dim MonthNO As Integer
Dim YearNo As Integer
Dim MatchAMT As Currency
Dim STCreteria As String
Dim FMTest As Form
Dim TAGValue As Integer
'Dim flno As Integer

Set FMTest = Forms!FROnScreenTest

TAGValue = FMTest.Tag




'Debug.Print TAGValue
'STCreteria = " Month(MatchMonth) =" & MonthNO & " AND EmployeeID=" & FLNo





'MthDate = DLookup("matchmonth", "TBMatchAmount")
'MatchAMT = DLookup("matchamount", "tbmatchamount")

MonthNO = Month(MthDate)
YearNo = Year(MthDate)


MonthlyAmt = DSum("matchamount", "tbmatchamount", " EmployeeID=" & FLNo & "" And "& MonthNo =" & 1)




'Debug.Print MonthlyAmt


End Function
 
Hey VS,
You need to tell us what line causes the error.
Mark
 
Hey VS,
You need to tell us what line causes the error.
Mark

The cell that create the error is this and I know that it happened on the " & MonthNo =" & 1:
MonthlyAmt = DSum("matchamount", "tbmatchamount", " EmployeeID=" & FLNo & "" And "& MonthNo =" & 1)
 
What happens if you do...
Code:
MonthlyAmt = DSum("matchamount", "tbmatchamount", " EmployeeID = " & FLNo & " And MonthNo = 1")
... which assumes MonthNo is a field in tbmatchamount, correct?
Mark
 
i think error starts here:

MonthNo = Month(MthDate)
Year = Year(MthDate)

variable MthDate is not declared.
or was it a Public variable?!?

if it is in Form FMTest, then
you should qualify it:


MonthNo = Month(FMTest!MthDate)
Year = Year(FMTest!MthDate)
 
..

variable MthDate is not declared.
..
Hmm - what is then the second code line?
Code:
Public Function MonthlyAmt(FLNo As Integer) As Currency

[B][COLOR=Red]Dim MthDate As Date[/COLOR][/B]
 
yes it was declared alright.
but not initialized.
to which MthDate are we referencing?
without initialization it was
used immediately on this line:

MonthNo=Month(MthDate)
YearNo=Year(MthDate)
 
MS Access “Type Mismatch In Expression” Error

Well I have too got this mismatch error in my MS Access application while handling expression. I completely unaware that how to fix this :banghead: and so I searched many sites for the solution and got this, hopefully you will also get some help from this. So just go through this.....
accessrepairnrecovery.com/blog/fix-access-3615-error-code
:rolleyes:;)
 
What happens if you do...
Code:
MonthlyAmt = DSum("matchamount", "tbmatchamount", " EmployeeID = " & FLNo & " And MonthNo = 1")
... which assumes MonthNo is a field in tbmatchamount, correct?
Mark

MonthNo is not a field on the tbmatchamount.

I previously tried to pull just the month from a field on the tbmatchamount and I could not get the correct information.

Month(matchmonth)

I just need the month number = to a variable that I create from information con the control tag (Tagvalue). The tag has 1 for January and I want to pull all the record from January and posted on the January column
 
Pass the date to your function along with the ID

Public Function MonthlyAmt(FLNo As Integer, dt as date) As Currency

MonthlyAmt = DSum("matchamount", "tbmatchamount", " EmployeeID=" & FLNo & " And Month(matchmonth)=" & Month(dt))

End Function
 

Users who are viewing this thread

Back
Top Bottom