A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Using Forms
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Syntax Error on DLookup



 
 
Thread Tools Display Modes
  #1  
Old January 4th, 2010, 06:33 PM posted to microsoft.public.access.forms
Pamela
external usenet poster
 
Posts: 193
Default Syntax Error on DLookup

I have a code that I've copied and used several times but it isn't working in
this one instance. The control to which this is attached is on a subform
nested 4 deep. The control to which it is referring "Measurements" is on
Subform3 (the parent of subform4). Here's my code:
DLookup("Expr1", "qryMeasurements", "Measurements = " &
Me.Parent!Measurements) & " "
Please let me know what I may be missing. Thanks so much!
Pamela
  #2  
Old January 4th, 2010, 06:36 PM posted to microsoft.public.access.forms
theDBguy[_2_]
external usenet poster
 
Posts: 29
Default Syntax Error on DLookup

Hi Pamela,

Not sure if this will work but try this syntax:

Me.Parent.Form!Measurements

Hope that helps...


"Pamela" wrote:

I have a code that I've copied and used several times but it isn't working in
this one instance. The control to which this is attached is on a subform
nested 4 deep. The control to which it is referring "Measurements" is on
Subform3 (the parent of subform4). Here's my code:
DLookup("Expr1", "qryMeasurements", "Measurements = " &
Me.Parent!Measurements) & " "
Please let me know what I may be missing. Thanks so much!
Pamela

  #3  
Old January 4th, 2010, 06:44 PM posted to microsoft.public.access.forms
Pamela
external usenet poster
 
Posts: 193
Default Syntax Error on DLookup

Hi DBguy,
Something I just realized is that I ONLY get this Syntax Error when the
field is skipped which is then Null. I do have an expression set in my query
to give a result for a null value but I think that's what's throwing this
off. Any suggestions for how to handle that??

"theDBguy" wrote:

Hi Pamela,

Not sure if this will work but try this syntax:

Me.Parent.Form!Measurements

Hope that helps...


"Pamela" wrote:

I have a code that I've copied and used several times but it isn't working in
this one instance. The control to which this is attached is on a subform
nested 4 deep. The control to which it is referring "Measurements" is on
Subform3 (the parent of subform4). Here's my code:
DLookup("Expr1", "qryMeasurements", "Measurements = " &
Me.Parent!Measurements) & " "
Please let me know what I may be missing. Thanks so much!
Pamela

  #4  
Old January 4th, 2010, 06:59 PM posted to microsoft.public.access.forms
Dorian
external usenet poster
 
Posts: 542
Default Syntax Error on DLookup

What kind of data is in Measurements?
If it is text rather than a number, you need to include the value in your
DLookup in single quotes. e.g.
"Measurements = '" Me.Parent!Measurements & "'")

I'd also lookup in Access help on Subforms especially how to refer to one
subforms controls from another.
-- Dorian
"Give someone a fish and they eat for a day; teach someone to fish and they
eat for a lifetime".


"Pamela" wrote:

I have a code that I've copied and used several times but it isn't working in
this one instance. The control to which this is attached is on a subform
nested 4 deep. The control to which it is referring "Measurements" is on
Subform3 (the parent of subform4). Here's my code:
DLookup("Expr1", "qryMeasurements", "Measurements = " &
Me.Parent!Measurements) & " "
Please let me know what I may be missing. Thanks so much!
Pamela

  #5  
Old January 4th, 2010, 07:07 PM posted to microsoft.public.access.forms
Linq Adams via AccessMonster.com
external usenet poster
 
Posts: 1,474
Default Syntax Error on DLookup

You syntax is for DLookUp() is incorrect for either Text or Numeric field.

Assuming that your reference to

Me.Parent!Measurements

is correct, in your original code (I haven't worked with sub/subforms like
this)

If Measurements is Numeric it would be:

DLookup("Expr1", "qryMeasurements", "Measurements = " & Me.Parent!
Measurements)

If Measurements is Text:

DLookup("Expr1", "qryMeasurements", "Measurements ='" & Me.Parent!
Measurements & "'")

--
There's ALWAYS more than one way to skin a cat!

Answers/posts based on Access 2000/2003

Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/For...forms/201001/1

  #6  
Old January 4th, 2010, 07:15 PM posted to microsoft.public.access.forms
Pamela
external usenet poster
 
Posts: 193
Default Syntax Error on DLookup

I tried that, Dorian, but it isn't giving me anything now - just as though
that code isn't there which perhaps is better than an error...LOL But it
isn't returning anything for that piece of code. The query to which this is
referring has an expression that if the Measurements value is null, then text
is returned stating that there are no measurements but otherwise, text is
concatenated w/ the text in my measurements control stating that the height
of the damage is __ inches.
Any other ideas???

"Dorian" wrote:

What kind of data is in Measurements?
If it is text rather than a number, you need to include the value in your
DLookup in single quotes. e.g.
"Measurements = '" Me.Parent!Measurements & "'")

I'd also lookup in Access help on Subforms especially how to refer to one
subforms controls from another.
-- Dorian
"Give someone a fish and they eat for a day; teach someone to fish and they
eat for a lifetime".


"Pamela" wrote:

I have a code that I've copied and used several times but it isn't working in
this one instance. The control to which this is attached is on a subform
nested 4 deep. The control to which it is referring "Measurements" is on
Subform3 (the parent of subform4). Here's my code:
DLookup("Expr1", "qryMeasurements", "Measurements = " &
Me.Parent!Measurements) & " "
Please let me know what I may be missing. Thanks so much!
Pamela

  #7  
Old January 4th, 2010, 07:48 PM posted to microsoft.public.access.forms
Pamela
external usenet poster
 
Posts: 193
Default Syntax Error on DLookup

Hi Linq,
The field is text, and I tried changing it to include the extra " ' "s that
you instructed and someone else instructed but I'm still not getting it to
work. With that, the code doesn't give an error but it literally returns
blank. Note though that my original code works perfectly IF there's a value
entered. I'm only having this problem if the field is null. Any additional
help would be really great!

"Linq Adams via AccessMonster.com" wrote:

You syntax is for DLookUp() is incorrect for either Text or Numeric field.

Assuming that your reference to

Me.Parent!Measurements

is correct, in your original code (I haven't worked with sub/subforms like
this)

If Measurements is Numeric it would be:

DLookup("Expr1", "qryMeasurements", "Measurements = " & Me.Parent!
Measurements)

If Measurements is Text:

DLookup("Expr1", "qryMeasurements", "Measurements ='" & Me.Parent!
Measurements & "'")

--
There's ALWAYS more than one way to skin a cat!

Answers/posts based on Access 2000/2003

Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/For...forms/201001/1

.

  #8  
Old January 4th, 2010, 07:58 PM posted to microsoft.public.access.forms
theDBguy[_2_]
external usenet poster
 
Posts: 29
Default Syntax Error on DLookup

Hi Pamela,

In that case, you could probably use an IIf() statement. For example:

=IIf(test for skipped record, "Record Skipped", DLookup(...))

Hope that helps...


"Pamela" wrote:

Hi DBguy,
Something I just realized is that I ONLY get this Syntax Error when the
field is skipped which is then Null. I do have an expression set in my query
to give a result for a null value but I think that's what's throwing this
off. Any suggestions for how to handle that??

"theDBguy" wrote:

Hi Pamela,

Not sure if this will work but try this syntax:

Me.Parent.Form!Measurements

Hope that helps...


"Pamela" wrote:

I have a code that I've copied and used several times but it isn't working in
this one instance. The control to which this is attached is on a subform
nested 4 deep. The control to which it is referring "Measurements" is on
Subform3 (the parent of subform4). Here's my code:
DLookup("Expr1", "qryMeasurements", "Measurements = " &
Me.Parent!Measurements) & " "
Please let me know what I may be missing. Thanks so much!
Pamela

 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 02:38 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.