PC Review


Reply
Thread Tools Rate Thread

DLookup Problem Within A Subform

 
 
sweeberry
Guest
Posts: n/a
 
      15th Apr 2009
I have a subform which contains a Unit Price field that I would like to
automatically populate when the Item Number is selected. I have a table
"Products" that contains all of these values. I have a DLookup function that
I thought would generate the output I wanted but when I put it as the control
source for the field I need to be looked up nothing appears in the text box
or #Error appears. Here is what my DLookup looks like:
=DLookup("[Unit Price]", "Products", "[Item Number]" = Forms!Order
Form!Order Details Subform![Item Number])
 
Reply With Quote
 
 
 
 
KARL DEWEY
Guest
Posts: n/a
 
      15th Apr 2009
Instead of a lookup why not join the Products table i your query for subform?

"sweeberry" wrote:

> I have a subform which contains a Unit Price field that I would like to
> automatically populate when the Item Number is selected. I have a table
> "Products" that contains all of these values. I have a DLookup function that
> I thought would generate the output I wanted but when I put it as the control
> source for the field I need to be looked up nothing appears in the text box
> or #Error appears. Here is what my DLookup looks like:
> =DLookup("[Unit Price]", "Products", "[Item Number]" = Forms!Order
> Form!Order Details Subform![Item Number])

 
Reply With Quote
 
Steve Schapel
Guest
Posts: n/a
 
      16th Apr 2009
Sweeberry,

You have the " in the wrong place. Plus you need to enclose the names of
the objects and controls that have spaces in their names with []s. Try it
like this:

=DLookup("[Unit Price]","Products","[Item Number]=[Forms]![Order
Form]![Order Details Subform]![Item Number]")

--
Steve Schapel, Microsoft Access MVP


"sweeberry" <(E-Mail Removed)> wrote in message
news:ABDBF491-90E5-4875-88B7-(E-Mail Removed)...
> I have a subform which contains a Unit Price field that I would like to
> automatically populate when the Item Number is selected. I have a table
> "Products" that contains all of these values. I have a DLookup function
> that
> I thought would generate the output I wanted but when I put it as the
> control
> source for the field I need to be looked up nothing appears in the text
> box
> or #Error appears. Here is what my DLookup looks like:
> =DLookup("[Unit Price]", "Products", "[Item Number]" = Forms!Order
> Form!Order Details Subform![Item Number])


 
Reply With Quote
 
sweeberry
Guest
Posts: n/a
 
      16th Apr 2009
Thanks Steve,

Unfortunately this doesn't solve the issue - I am still getting a "#Error"
in the field I want to populate.

I have tried using this same expression as a Macro On Click, and as a VBA
event procedure, and have been unsuccessful. I always either get no result
at all or a "#Error".

Any thoughts?

"Steve Schapel" wrote:

> Sweeberry,
>
> You have the " in the wrong place. Plus you need to enclose the names of
> the objects and controls that have spaces in their names with []s. Try it
> like this:
>
> =DLookup("[Unit Price]","Products","[Item Number]=[Forms]![Order
> Form]![Order Details Subform]![Item Number]")
>
> --
> Steve Schapel, Microsoft Access MVP
>
>
> "sweeberry" <(E-Mail Removed)> wrote in message
> news:ABDBF491-90E5-4875-88B7-(E-Mail Removed)...
> > I have a subform which contains a Unit Price field that I would like to
> > automatically populate when the Item Number is selected. I have a table
> > "Products" that contains all of these values. I have a DLookup function
> > that
> > I thought would generate the output I wanted but when I put it as the
> > control
> > source for the field I need to be looked up nothing appears in the text
> > box
> > or #Error appears. Here is what my DLookup looks like:
> > =DLookup("[Unit Price]", "Products", "[Item Number]" = Forms!Order
> > Form!Order Details Subform![Item Number])

>
>

 
Reply With Quote
 
Steve Schapel
Guest
Posts: n/a
 
      16th Apr 2009
Sweeberry,

I don't know what you mean about using the expression in a macro or VBA
procedure.

But anyway, the most likely cause of the problem is that the Name of the
control is the same as the name of one of the fields in the form's Record
Source table/query. Change the name of the textbox.

--
Steve Schapel, Microsoft Access MVP


"sweeberry" <(E-Mail Removed)> wrote in message
news:1BF41E2B-1A0A-4DCA-88A7-(E-Mail Removed)...
> Thanks Steve,
>
> Unfortunately this doesn't solve the issue - I am still getting a "#Error"
> in the field I want to populate.
>
> I have tried using this same expression as a Macro On Click, and as a VBA
> event procedure, and have been unsuccessful. I always either get no
> result
> at all or a "#Error".
>



 
Reply With Quote
 
sweeberry
Guest
Posts: n/a
 
      17th Apr 2009
Steve,

I mean, I have written this same DLookup as a macro and assigned it to occur
On Click for the field I want populated with no result. I have also written
the VBA code as an On_Click event with no result.

And, I have already re-named the text box with no result.

I'm really stumped! I appreciate your help

"Steve Schapel" wrote:

> Sweeberry,
>
> I don't know what you mean about using the expression in a macro or VBA
> procedure.
>
> But anyway, the most likely cause of the problem is that the Name of the
> control is the same as the name of one of the fields in the form's Record
> Source table/query. Change the name of the textbox.
>
> --
> Steve Schapel, Microsoft Access MVP
>
>
> "sweeberry" <(E-Mail Removed)> wrote in message
> news:1BF41E2B-1A0A-4DCA-88A7-(E-Mail Removed)...
> > Thanks Steve,
> >
> > Unfortunately this doesn't solve the issue - I am still getting a "#Error"
> > in the field I want to populate.
> >
> > I have tried using this same expression as a Macro On Click, and as a VBA
> > event procedure, and have been unsuccessful. I always either get no
> > result
> > at all or a "#Error".
> >

>
>
>

 
Reply With Quote
 
Steve Schapel
Guest
Posts: n/a
 
      17th Apr 2009
Sweeberry,

I do not understand the concept of "written this same DLookup as a macro".
What is the macro? Can you tell us the actions you are using?

--
Steve Schapel, Microsoft Access MVP


"sweeberry" <(E-Mail Removed)> wrote in message
news:B13EBA14-1392-420E-99DF-(E-Mail Removed)...
> Steve,
>
> I mean, I have written this same DLookup as a macro and assigned it to
> occur
> On Click for the field I want populated with no result. I have also
> written
> the VBA code as an On_Click event with no result.
>
> And, I have already re-named the text box with no result.
>



 
Reply With Quote
 
Steve Schapel
Guest
Posts: n/a
 
      17th Apr 2009
Sweeberry,

Here's another thought... Is your ItemNumber actually a number? I.e. is
this field a Number data type, or is it Text?

--
Steve Schapel, Microsoft Access MVP


"sweeberry" <(E-Mail Removed)> wrote in message
news:B13EBA14-1392-420E-99DF-(E-Mail Removed)...
> Steve,
>
> I mean, I have written this same DLookup as a macro and assigned it to
> occur
> On Click for the field I want populated with no result. I have also
> written
> the VBA code as an On_Click event with no result.
>
> And, I have already re-named the text box with no result.
>



 
Reply With Quote
 
sfisher973
Guest
Posts: n/a
 
      4th May 2009
Steve Shapel introduced other errors. Assumming [Item Number] is a Number
Field, try the following:

=DLookup("[Unit Price]","Products","[Item Number] = " & [Forms]![Order
Form]![Order Details Subform]![Item Number])

--
-Steve


"sweeberry" wrote:

> Thanks Steve,
>
> Unfortunately this doesn't solve the issue - I am still getting a "#Error"
> in the field I want to populate.
>
> I have tried using this same expression as a Macro On Click, and as a VBA
> event procedure, and have been unsuccessful. I always either get no result
> at all or a "#Error".
>
> Any thoughts?
>
> "Steve Schapel" wrote:
>
> > Sweeberry,
> >
> > You have the " in the wrong place. Plus you need to enclose the names of
> > the objects and controls that have spaces in their names with []s. Try it
> > like this:
> >
> > =DLookup("[Unit Price]","Products","[Item Number]=[Forms]![Order
> > Form]![Order Details Subform]![Item Number]")
> >
> > --
> > Steve Schapel, Microsoft Access MVP
> >
> >
> > "sweeberry" <(E-Mail Removed)> wrote in message
> > news:ABDBF491-90E5-4875-88B7-(E-Mail Removed)...
> > > I have a subform which contains a Unit Price field that I would like to
> > > automatically populate when the Item Number is selected. I have a table
> > > "Products" that contains all of these values. I have a DLookup function
> > > that
> > > I thought would generate the output I wanted but when I put it as the
> > > control
> > > source for the field I need to be looked up nothing appears in the text
> > > box
> > > or #Error appears. Here is what my DLookup looks like:
> > > =DLookup("[Unit Price]", "Products", "[Item Number]" = Forms!Order
> > > Form!Order Details Subform![Item Number])

> >
> >

 
Reply With Quote
 
Steve Schapel
Guest
Posts: n/a
 
      4th May 2009
Steve,

Yes, you can do it like that, if you like. Or you can do it the way I did
it. Either will be fine. I don't think the suggestion you introduced will
be relevant to Sweeberry's problem.

--
Steve Schapel, Microsoft Access MVP


"sfisher973" <(E-Mail Removed)> wrote in message
news:E5421D50-4C12-4CBE-8397-(E-Mail Removed)...
> Steve Shapel introduced other errors. Assumming [Item Number] is a Number
> Field, try the following:
>
> =DLookup("[Unit Price]","Products","[Item Number] = " & [Forms]![Order
> Form]![Order Details Subform]![Item Number])



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Dlookup Subform Problem DubboPete Microsoft Access Form Coding 2 27th Jun 2008 03:43 PM
Help with Dlookup problem in subform/main form nybaseball22@gmail.com Microsoft Access Form Coding 1 14th Nov 2007 10:19 PM
DLookup in subform =?Utf-8?B?a2FzYWI=?= Microsoft Access Forms 11 19th Sep 2007 12:20 PM
DLOOKUP from a subform =?Utf-8?B?Um9iZXJ0X0xfUm9zcw==?= Microsoft Access Form Coding 5 24th May 2006 12:35 PM
Help with DLookUp on subform Steve Perrins Microsoft Access 2 6th Mar 2006 06:53 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 02:43 PM.