Hi, guys, and thanks for reading my post. First of all I want to say thet I've only been using VBA and Access for 1 month so my knowledge about programming is low. I've been checking several tutorials and threads on the net to get this solved, but still I could not find a solution and my headache is big enough to try to ask for help from experiencied users.
Basically my main problem is that I can't fully understand how to make work the criteria in functions (VBA), specially in the WHERE clause. :banghead:
In my particular example, what I'm trying to do is to check if it exists a particular record in a table and if so, to execute an action.
This is the code I've been using so far and even without fully understanding when and where to use ", &, '... I've managed to make it work with simple expressions but when I try to add multiple criteria on them, several errors show up, even after trying with all the possible combinations that came up to my mind.
I apologize in advance if this thread has been exposed somewhere else, I could not find it. Also if there is any post where this kind of expressions is explained in detail I would like to check it out so I can finally understand how to build this by myself and when to use this different operators.
Thanks a lot!
Basically my main problem is that I can't fully understand how to make work the criteria in functions (VBA), specially in the WHERE clause. :banghead:
In my particular example, what I'm trying to do is to check if it exists a particular record in a table and if so, to execute an action.
Code:
Sub Test()
Dim strIDM As String
Dim cGreen As Long
Dim cGray As Long
strIDM = 101
cGreen = RGB(157, 187, 97)
cGray = RGB(165, 165, 165)
If (DCount("[IDMaq_FK]", "tblBobinas", "[Status]= 'On production' AND [IDMaq_FK]= & strIDM") > 0 Then
Me.box101.BackColor = cGreen
Else
Me.box101.BackColor = cGray
End If
End Sub
This is the code I've been using so far and even without fully understanding when and where to use ", &, '... I've managed to make it work with simple expressions but when I try to add multiple criteria on them, several errors show up, even after trying with all the possible combinations that came up to my mind.
I apologize in advance if this thread has been exposed somewhere else, I could not find it. Also if there is any post where this kind of expressions is explained in detail I would like to check it out so I can finally understand how to build this by myself and when to use this different operators.
Thanks a lot!