Hello all! I was hoping one of the experts here might be able to help me.
I am trying to create a number generator that counts the number of entries in a table where the criteria in the form of entries in a textbox are met. This is the code that I have so far:
Code:
Dim Ent As StringDim Modl As String
Dim Typ As String
Dim Root As String
Dim RICEWID As Integer
'Check to see if there is any missing information
If Not IsNull(Me![Entity]) And Not IsNull(Me![Module]) And Not IsNull(Me![Type]) Then
'Stick field values into the variables
Modl = Me![ModuleTB]
Typ = Me![TypeTB]
Ent = Me![EntityTB]
Root = [Modl] & "-" & [Typ] & "-" & [Ent]
RICEWID = DCount("[Entity]", "RICEW_ID_GEN", "[Entity]=" & Ent)
'RICEWID = DCount("[Module]", "RICEW_ID_GEN", "[Entity] = 'HH'")
MsgBox ([Root])
MsgBox ([RICEWID])
Else
'Missing information escape message
MsgBox ("You done screwed up.")
End If
End Sub
On the line that the RICEWID variable is defined, the DCount function works fine as long as I pass it a string "[Entity] = 'HH'" but as soon as I remove the constant and insert the variable, I get Runtime Error 2471, despite the fact that the variable ='HH'. To me it looks like I'm passing the same info into the DCount criteria but clearly I'm missing something. Any help would be greatly appreciated.
Justin