Mismatch Error 13 with dates (1 Viewer)

VSolano

Registered User.
Local time
Today, 17:17
Joined
Feb 21, 2017
Messages
85
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
 

MarkK

bit cruncher
Local time
Today, 14:17
Joined
Mar 17, 2004
Messages
8,181
Hey VS,
You need to tell us what line causes the error.
Mark
 

VSolano

Registered User.
Local time
Today, 17:17
Joined
Feb 21, 2017
Messages
85
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)
 

MarkK

bit cruncher
Local time
Today, 14:17
Joined
Mar 17, 2004
Messages
8,181
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
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Tomorrow, 05:17
Joined
May 7, 2009
Messages
19,242
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)
 

JHB

Have been here a while
Local time
Today, 23:17
Joined
Jun 17, 2012
Messages
7,732
..

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]
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Tomorrow, 05:17
Joined
May 7, 2009
Messages
19,242
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)
 

edwards142

New member
Local time
Today, 14:17
Joined
Jun 18, 2015
Messages
3
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:;)
 

VSolano

Registered User.
Local time
Today, 17:17
Joined
Feb 21, 2017
Messages
85
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
 

static

Registered User.
Local time
Today, 22:17
Joined
Nov 2, 2015
Messages
823
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

Top Bottom