- If DLookup("TS_ID", "TestsForScripts", "[Ref_ID]=" & Me.Ref_ID & " AND " & "[ExpectedResult]='" & Me.ExpectedResult & "'") = "" Then
Can anyone see anything wrong with this code? It keeps throwing up a Run Time Error 3075 message, saying there's a syntax error and I can't spot any.
Ref_ID is a numerical field, and ExpectedResult is a string based field.
Thanks.
I would guess that your problem comes from the fact that you have a single quote as a value in your expected results. Access so neatly handles the special charecters as long as they are in a field that we seldom remember (myself included) to handle them in vba.
Try this: - If DLookup("TS_ID", "TestsForScripts", "[Ref_ID]=" & Me.Ref_ID & " AND " & "[ExpectedResult]='" & Replace(Me.ExpectedResult,"'","''") & "'") = "" Then
7 5067
You are trying to compare to an empty string. Usually Access does not store empty strings. If the field has not been used, it will be null, not a zero length string. You need to understand that there is a big difference between the two.
If you are worried that a DLookup could return null, there are a few things to do:
Enclose it in Nz, like so:
If Dlookup returns a value the value gets returned from nz. If Dlookup returns Null, the empty string is returned.
A simpler way, which only works for strings, is to take advantage of the fact that: Null & ""="" - If Dlookup() & ""="" then
-
'Null was returned
-
End IF
While I understand what you say, that isn't where the problem lies. The problem seems to exist in the dlookup itself, not the comparison.
The entire error message that comes up is:
Run-time error ‘3075’:
Syntax error (missing operator) in query expression ‘[Ref_ID]=410 AND [ExpectedResult]=’Invalid login details are blocked by the system, and the user is prompted that the details aren’t valid.”.
Don't know if that gives any clues.
From what I've deduced, the problem seems to be with ExpectedResult. This is only one field of many that are supposed to be in the criteria, and doing a dlookup with all fields except ExpectedResult runs without a problem. :S
Hi
Not withstanding TheSmileyCoder's excellent advice, I think your DLookUp() should be like this - DLookup("TS_ID", "TestsForScripts", "[Ref_ID]=" & Me.Ref_ID & " AND [ExpectedResult]='" & Me.ExpectedResult & "'")
assuming Ref_ID is numeric and ExpectedResult is text
??
MTB
I would guess that your problem comes from the fact that you have a single quote as a value in your expected results. Access so neatly handles the special charecters as long as they are in a field that we seldom remember (myself included) to handle them in vba.
Try this: - If DLookup("TS_ID", "TestsForScripts", "[Ref_ID]=" & Me.Ref_ID & " AND " & "[ExpectedResult]='" & Replace(Me.ExpectedResult,"'","''") & "'") = "" Then
Once again SmileyCoder, you seem to have struck gold! The single quote in the value seems to be causing problems, and putting in your suggestion has solved the problem. I'll have to remember this one!
Thanks for the help.
So much for me remembering this one - just got linked back to this thread while searching for an answer to the same problem!
Sign in to post your reply or Sign up for a free account.
Similar topics
by: shank |
last post by:
1) I'm getting this error: Syntax error (missing operator) in query
expression on the below statement. Can I get some advice.
2) I searched ASPFAQ and came up blank. Where can find the "rules"...
|
by: Jack |
last post by:
What is the syntax for the criteria in DLookup in a subform to refer to a
control (MyControl) on the subform? I have tried the following and none seem
to work:
" = " &...
|
by: shifty shaker |
last post by:
I've modified sql text and now i'm getting a syntax error that I cannot
figure out....anyone?
error occurs at the Insert Into line but the entire function is given in
case you need it.
---...
|
by: Thelma Lubkin |
last post by:
I would like my DLookup criteria to say this: Trim(fieldX) = strVar:
myVar = _
DLookup("someField", "someTable", "Trim(fieldX) = '" & strVar & '")
I don't believe that this will work, and I...
|
by: tasmontique |
last post by:
Hello everyone,
I keep getting a syntax error in my update statement. The only thing that I notice is
that although the columns in my table have the same name as the fields on the form the...
|
by: injanib via AccessMonster.com |
last post by:
Hello Access Monsters,
I have a table with three columns. "CostCenter", "ProjectNumber", "GLCode"
On my form I have three texboxes, "txtCostCenter", "txtProjectNumber" and
"txtGLCode".
the...
|
by: ramprat |
last post by:
Hi everyone,
This one is stumping me really good. The query entered in my filter below will work as a stand alone query in Access but I keep getting a syntax error when I try to run it through a...
|
by: rolltide |
last post by:
I've seen many similar threads, but despite repeated efforts I cannot figure out my problem. I am running Access 2003, VB 6.5, Office XP Pro. Code excerpt is below (you can see where I've tried...
|
by: GLEberts |
last post by:
I can not seem to get rid of this syntax error - hope someone can help out.
the error I am getting is:
Run time Error 3075
Syntax error missing operator in query expression
=name
I have...
|
by: JpjVB |
last post by:
I'm having difficulty filtering a form using a multiselect list box when using some Allen Browne code. I get the error "Syntax Error (missing operator)in query expression '( IN (""Sydney"London)'. -...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
| |