Hopefully someone can help me out with this. I have written a query in Access 2003 that combines a linked table "taxon_group_max_per_site"
and a cross tab query "Distinct Species by group_Crosstab".
From the table I have the field "Taxonomic Group"
and "Max"
, and from the cross tab the fields "Total_Of_Species_S"
.
The table and the cross tab are linked and the query works fine until I add in some VBA to give each Taxonomic group a score based on "Max"
and "Total_Of_Species_S"
.
The code below brings up "Error 13: type mismatch"
Public Function Invert_Diversity_Score (Total_Of_Species_S As Integer) As Integer
If Total_Of_Species_S < Round("[Max]*0.5", 0) Then
Invert_Diversity_Score = 0
Else
If Total_Of_Species_S < Round("[Max] * 0.75", 0) Then
Invert_Diversity_Score = 1
Else
If Total_Of_Species_S < Round("[Max] * 0.875", 0) Then
Invert_Diversity_Score = 2
Else
Invert_Diversity_Score = 3
End If
End If
End If
End Function
The debugger shows that "[Max]*0.5"
and the other multiplications do not produce a number it says "[Max] * 0.5"= "[Max] * 0.5"
, which I think is the source of the type mismatch. How do I get the field to multiple properly? It looks exactly like the format shown in the VBA help.