dbTalk Databases Forums  

embeded Dlookup

comp.databases.ms-access comp.databases.ms-access


Discuss embeded Dlookup in the comp.databases.ms-access forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
WhathaveIdone?
 
Posts: n/a

Default embeded Dlookup - 09-16-2010 , 11:00 AM






This may be an easy enough fix. It may be challenging though, so if
you are up to the task, I'd love your thoughts. But those of you who
are familiar with Allen Browne, he has been a lifesaver to me and is
an absolute genius. I am using his ConcatRelated Function utility.
http://allenbrowne.com/func-concat.html I have a layout as such:

tblStates with fields: StateID (autonumber), StateAbb, and StateName
tblProducts including field: ProdID(autonumber)
tblProdState with fields: ProdID, StateID

I am treating this as a many to many relationship because many states
can have many products and many products can have many states. (i.e.
Product1 is available in AL,GA,NY; Product2 is available in CA, GA,
MI, NY, UT)
1st Question: Is this an appropriate relationship?

I am using Allen Browne's ConcatRelated Function utility
http://allenbrowne.com/func-concat.html to show this on a form:
frmMain.txtStates
the ConcatRelated function is working perfectly. The ConcatRelated
shows the list of related data per record on my form separated by
",".
However, I want to show the StateAbb for each of the stateID's in
txtStates instead of the StateID in that list. So, I have not been
able to successfully nest a dlookup function into that function.
2nd Question: Any thoughts about where to do that and/or how?

Reply With Quote
  #2  
Old   
Salad
 
Posts: n/a

Default Re: embeded Dlookup - 09-16-2010 , 11:48 AM






WhathaveIdone? wrote:

Quote:
This may be an easy enough fix. It may be challenging though, so if
you are up to the task, I'd love your thoughts. But those of you who
are familiar with Allen Browne, he has been a lifesaver to me and is
an absolute genius. I am using his ConcatRelated Function utility.
http://allenbrowne.com/func-concat.html I have a layout as such:

tblStates with fields: StateID (autonumber), StateAbb, and StateName
tblProducts including field: ProdID(autonumber)
tblProdState with fields: ProdID, StateID

I am treating this as a many to many relationship because many states
can have many products and many products can have many states. (i.e.
Product1 is available in AL,GA,NY; Product2 is available in CA, GA,
MI, NY, UT)
1st Question: Is this an appropriate relationship?

I am using Allen Browne's ConcatRelated Function utility
http://allenbrowne.com/func-concat.html to show this on a form:
frmMain.txtStates
the ConcatRelated function is working perfectly. The ConcatRelated
shows the list of related data per record on my form separated by
",".
However, I want to show the StateAbb for each of the stateID's in
txtStates instead of the StateID in that list. So, I have not been
able to successfully nest a dlookup function into that function.
2nd Question: Any thoughts about where to do that and/or how?

Without a "small" example of your desired output or an example or your
SQL statment it would be hard for someone to make a really valid suggestion.

Your statement "However, I want to show the StateAbb for each of the
stateID's in txtStates instead of the StateID in that list." What does
that mean? Does it work but you are getting a state number instead of
abbreaviation? What is a small example of your current output?

Allen's examples use a "table" to use in the concatenation. You could
use a query if you need to concatenate multiple fields.
Select [Name] & "-" & [Addr1] As NameAndAddress From ...
and use that query in your concatenation function.

Reply With Quote
  #3  
Old   
WhathaveIdone?
 
Posts: n/a

Default Re: embeded Dlookup - 09-16-2010 , 12:05 PM



On Sep 16, 10:48*am, Salad <sa... (AT) oilandvinegar (DOT) com> wrote:
Quote:
WhathaveIdone? wrote:
This may be an easy enough fix. It may be challenging though, so if
you are up to the task, I'd love your thoughts. But those of you who
are familiar with Allen Browne, he has been a lifesaver to me and is
an absolute genius. I am using his ConcatRelated Function utility.
http://allenbrowne.com/func-concat.html*I have a layout as such:

tblStates with fields: StateID (autonumber), StateAbb, and StateName
tblProducts including field: ProdID(autonumber)
tblProdState with fields: ProdID, StateID

I am treating this as a many to many relationship because many states
can have many products and many products can have many states. (i.e.
Product1 is available in AL,GA,NY; Product2 is available in CA, GA,
MI, NY, UT)
1st Question: Is this an appropriate relationship?

I am using Allen Browne's ConcatRelated Function utility
http://allenbrowne.com/func-concat.htmlto show this on a form:
frmMain.txtStates
the ConcatRelated function is working perfectly. The ConcatRelated
shows the list of related data per record on my form separated by
",".
However, I want to show the StateAbb for each of the stateID's in
txtStates instead of the StateID in that list. So, I have not been
able to successfully nest a dlookup function into that function.
2nd Question: Any thoughts about where to do that and/or how?

Without a "small" example of your desired output or an example or your
SQL statment it would be hard for someone to make a really valid suggestion.

Your statement "However, I want to show the StateAbb for each of the
stateID's in txtStates instead of the StateID in that list." *What does
that mean? *Does it work but you are getting a state number instead of
abbreaviation? *What is a small example of your current output?

Allen's examples use a "table" to use in the concatenation. *You could
use a query if you need to concatenate multiple fields.
* *Select [Name] & "-" & [Addr1] As NameAndAddress From ...
and use that query in your concatenation function.
I always worry about making sure I have enough information in a post
to let others know what I am doing. So I appologize if it is not clear
enough. Let me try and explain.
I am doing my best to keep this normalized in my DB as best I can. I
have a text box on a form where I have used the function from Allen
Browne's ConcatRelated utility. That function pulls the data as such:

=ConcatRelated("StateID","tblProdState","ProdID =" & [ProdID])
(The form is based on the table tblProducts and so it includes the
field ProdID from that table)
tblStates M:M tblProducts (therefore, I have tblProdState to try and
normalize the data)

From the ConcatRelated function, I get the StateID's separated by
commas(ex: 3, 15, 46) where I would like, instead, to show the
corresponding StateAbb from the tblStates table (ex:AL, TX, VA) where
StateID corresponds . Normally, I would use Dlookup to get the value I
want from the tblStates table for a single value in my txtStates
control on the form. But where this field has multiple values for each
of the ProdID records, I don't know as readily where to put or how to
use the Dlookup function in this case, or if I would even need to use
it at all (i.e.query or other alternative) I hope that didn't just
confuse things more and I was a little bit more descriptive of the
issue. But please let me know if you have questions.
-WhathaveIdone?

Reply With Quote
  #4  
Old   
Salad
 
Posts: n/a

Default Re: embeded Dlookup - 09-16-2010 , 01:44 PM



WhathaveIdone? wrote:

Quote:
On Sep 16, 10:48 am, Salad <sa... (AT) oilandvinegar (DOT) com> wrote:

WhathaveIdone? wrote:

This may be an easy enough fix. It may be challenging though, so if
you are up to the task, I'd love your thoughts. But those of you who
are familiar with Allen Browne, he has been a lifesaver to me and is
an absolute genius. I am using his ConcatRelated Function utility.
http://allenbrowne.com/func-concat.html I have a layout as such:

tblStates with fields: StateID (autonumber), StateAbb, and StateName
tblProducts including field: ProdID(autonumber)
tblProdState with fields: ProdID, StateID

I am treating this as a many to many relationship because many states
can have many products and many products can have many states. (i.e.
Product1 is available in AL,GA,NY; Product2 is available in CA, GA,
MI, NY, UT)
1st Question: Is this an appropriate relationship?

I am using Allen Browne's ConcatRelated Function utility
http://allenbrowne.com/func-concat.htmlto show this on a form:
frmMain.txtStates
the ConcatRelated function is working perfectly. The ConcatRelated
shows the list of related data per record on my form separated by
",".
However, I want to show the StateAbb for each of the stateID's in
txtStates instead of the StateID in that list. So, I have not been
able to successfully nest a dlookup function into that function.
2nd Question: Any thoughts about where to do that and/or how?

Without a "small" example of your desired output or an example or your
SQL statment it would be hard for someone to make a really valid suggestion.

Your statement "However, I want to show the StateAbb for each of the
stateID's in txtStates instead of the StateID in that list." What does
that mean? Does it work but you are getting a state number instead of
abbreaviation? What is a small example of your current output?

Allen's examples use a "table" to use in the concatenation. You could
use a query if you need to concatenate multiple fields.
Select [Name] & "-" & [Addr1] As NameAndAddress From ...
and use that query in your concatenation function.


I always worry about making sure I have enough information in a post
to let others know what I am doing. So I appologize if it is not clear
enough. Let me try and explain.
I am doing my best to keep this normalized in my DB as best I can. I
have a text box on a form where I have used the function from Allen
Browne's ConcatRelated utility. That function pulls the data as such:

=ConcatRelated("StateID","tblProdState","ProdID =" & [ProdID])
(The form is based on the table tblProducts and so it includes the
field ProdID from that table)
tblStates M:M tblProducts (therefore, I have tblProdState to try and
normalize the data)

From the ConcatRelated function, I get the StateID's separated by
commas(ex: 3, 15, 46) where I would like, instead, to show the
corresponding StateAbb from the tblStates table (ex:AL, TX, VA) where
StateID corresponds . Normally, I would use Dlookup to get the value I
want from the tblStates table for a single value in my txtStates
control on the form. But where this field has multiple values for each
of the ProdID records, I don't know as readily where to put or how to
use the Dlookup function in this case, or if I would even need to use
it at all (i.e.query or other alternative) I hope that didn't just
confuse things more and I was a little bit more descriptive of the
issue. But please let me know if you have questions.
-WhathaveIdone?
In Allen's example he has
SELECT CompanyName, ConcatRelated("OrderDate", "tblOrders",
"CompanyID = " & [CompanyID])
FROM tblCompany;

So add StateAbbr to your list in the Select statement.
Or
=ConcatRelated("StateAbbr","tblProdState","ProdID =" & [ProdID])

You use tblProdState. I'd substitute that with a query most likely.
I'd link the state table with tblProdState and be done with it. Ex:
=ConcatRelated("StateAbbr","qryProdState","ProdID =" & [ProdID])

It seems pretty basic, your problem. I suppose you can make it more
complicated than it is. Then again, I may not understand your problem.

Reply With Quote
  #5  
Old   
WhathaveIdone?
 
Posts: n/a

Default Re: embeded Dlookup - 09-16-2010 , 03:30 PM



On Sep 16, 12:44*pm, Salad <sa... (AT) oilandvinegar (DOT) com> wrote:
Quote:
WhathaveIdone? wrote:
On Sep 16, 10:48 am, Salad <sa... (AT) oilandvinegar (DOT) com> wrote:

WhathaveIdone? wrote:

This may be an easy enough fix. It may be challenging though, so if
you are up to the task, I'd love your thoughts. But those of you who
are familiar with Allen Browne, he has been a lifesaver to me and is
an absolute genius. I am using his ConcatRelated Function utility.
http://allenbrowne.com/func-concat.htmlI have a layout as such:

tblStates with fields: StateID (autonumber), StateAbb, and StateName
tblProducts including field: ProdID(autonumber)
tblProdState with fields: ProdID, StateID

I am treating this as a many to many relationship because many states
can have many products and many products can have many states. (i.e.
Product1 is available in AL,GA,NY; Product2 is available in CA, GA,
MI, NY, UT)
1st Question: Is this an appropriate relationship?

I am using Allen Browne's ConcatRelated Function utility
http://allenbrowne.com/func-concat.htmltoshow this on a form:
frmMain.txtStates
the ConcatRelated function is working perfectly. The ConcatRelated
shows the list of related data per record on my form separated by
",".
However, I want to show the StateAbb for each of the stateID's in
txtStates instead of the StateID in that list. So, I have not been
able to successfully nest a dlookup function into that function.
2nd Question: Any thoughts about where to do that and/or how?

Without a "small" example of your desired output or an example or your
SQL statment it would be hard for someone to make a really valid suggestion.

Your statement "However, I want to show the StateAbb for each of the
stateID's in txtStates instead of the StateID in that list." *What does
that mean? *Does it work but you are getting a state number instead of
abbreaviation? *What is a small example of your current output?

Allen's examples use a "table" to use in the concatenation. *You could
use a query if you need to concatenate multiple fields.
* Select [Name] & "-" & [Addr1] As NameAndAddress From ...
and use that query in your concatenation function.

I always worry about making sure I have enough information in a post
to let others know what I am doing. So I appologize if it is not clear
enough. Let me try and explain.
I am doing my best to keep this normalized in my DB as best I can. I
have a text box on a form where I have used the function from Allen
Browne's ConcatRelated utility. That function pulls the data as such:

=ConcatRelated("StateID","tblProdState","ProdID =" & [ProdID])
(The form is based on the table tblProducts and so it includes the
field ProdID from that table)
tblStates M:M tblProducts (therefore, I have tblProdState to try and
normalize the data)

From the ConcatRelated function, I get the StateID's separated by
commas(ex: 3, 15, 46) *where I would like, instead, to show the
corresponding StateAbb from the tblStates table (ex:AL, TX, VA) where
StateID corresponds . Normally, I would use Dlookup to get the value I
want from the tblStates table for a single value in my txtStates
control on the form. But where this field has multiple values for each
of the ProdID records, I don't know as readily where to put or how to
use the Dlookup function in this case, or if I would even need to use
it at all (i.e.query or other alternative) I hope that didn't just
confuse things more and I was a little bit more descriptive of the
issue. But please let me know if you have questions.
-WhathaveIdone?

In Allen's example he has
* SELECT CompanyName, *ConcatRelated("OrderDate", "tblOrders",
"CompanyID * = " & [CompanyID])
* *FROM tblCompany;

So add StateAbbr to your list in the Select statement.
* *Or
=ConcatRelated("StateAbbr","tblProdState","ProdID =" & [ProdID])

You use tblProdState. *I'd substitute that with a query most likely.
I'd link the state table with tblProdState and be done with it. *Ex:
* *=ConcatRelated("StateAbbr","qryProdState","ProdID =" & [ProdID])

It seems pretty basic, your problem. *I suppose you can make it more
complicated than it is. *Then again, I may not understand your problem.

You totally solved my problem!! I knew I had to be making it way
harder than it had to be.
So I created qryProdState from tblProdState. I added a field
Statelookup("State","qryProdState","StateID = " & [StateID])
Then, I put =ConcatRelated("State","qryProdState","ProdID =" &
[ProdID])

Sometimes, you just have to bounce it off someone to see things
clearly. I could have made a real mess of this one. Thanks!!

-WhathaveIdone?

Reply With Quote
  #6  
Old   
Salad
 
Posts: n/a

Default Re: embeded Dlookup - 09-16-2010 , 04:04 PM



WhathaveIdone? wrote:

Quote:
On Sep 16, 12:44 pm, Salad <sa... (AT) oilandvinegar (DOT) com> wrote:

WhathaveIdone? wrote:

On Sep 16, 10:48 am, Salad <sa... (AT) oilandvinegar (DOT) com> wrote:

WhathaveIdone? wrote:

This may be an easy enough fix. It may be challenging though, so if
you are up to the task, I'd love your thoughts. But those of you who
are familiar with Allen Browne, he has been a lifesaver to me and is
an absolute genius. I am using his ConcatRelated Function utility.
http://allenbrowne.com/func-concat.htmlI have a layout as such:

tblStates with fields: StateID (autonumber), StateAbb, and StateName
tblProducts including field: ProdID(autonumber)
tblProdState with fields: ProdID, StateID

I am treating this as a many to many relationship because many states
can have many products and many products can have many states. (i.e.
Product1 is available in AL,GA,NY; Product2 is available in CA, GA,
MI, NY, UT)
1st Question: Is this an appropriate relationship?

I am using Allen Browne's ConcatRelated Function utility
http://allenbrowne.com/func-concat.htmltoshow this on a form:
frmMain.txtStates
the ConcatRelated function is working perfectly. The ConcatRelated
shows the list of related data per record on my form separated by
",".
However, I want to show the StateAbb for each of the stateID's in
txtStates instead of the StateID in that list. So, I have not been
able to successfully nest a dlookup function into that function.
2nd Question: Any thoughts about where to do that and/or how?

Without a "small" example of your desired output or an example or your
SQL statment it would be hard for someone to make a really valid suggestion.

Your statement "However, I want to show the StateAbb for each of the
stateID's in txtStates instead of the StateID in that list." What does
that mean? Does it work but you are getting a state number instead of
abbreaviation? What is a small example of your current output?

Allen's examples use a "table" to use in the concatenation. You could
use a query if you need to concatenate multiple fields.
Select [Name] & "-" & [Addr1] As NameAndAddress From ...
and use that query in your concatenation function.

I always worry about making sure I have enough information in a post
to let others know what I am doing. So I appologize if it is not clear
enough. Let me try and explain.
I am doing my best to keep this normalized in my DB as best I can. I
have a text box on a form where I have used the function from Allen
Browne's ConcatRelated utility. That function pulls the data as such:

=ConcatRelated("StateID","tblProdState","ProdID =" & [ProdID])
(The form is based on the table tblProducts and so it includes the
field ProdID from that table)
tblStates M:M tblProducts (therefore, I have tblProdState to try and
normalize the data)

From the ConcatRelated function, I get the StateID's separated by
commas(ex: 3, 15, 46) where I would like, instead, to show the
corresponding StateAbb from the tblStates table (ex:AL, TX, VA) where
StateID corresponds . Normally, I would use Dlookup to get the value I
want from the tblStates table for a single value in my txtStates
control on the form. But where this field has multiple values for each
of the ProdID records, I don't know as readily where to put or how to
use the Dlookup function in this case, or if I would even need to use
it at all (i.e.query or other alternative) I hope that didn't just
confuse things more and I was a little bit more descriptive of the
issue. But please let me know if you have questions.
-WhathaveIdone?

In Allen's example he has
SELECT CompanyName, ConcatRelated("OrderDate", "tblOrders",
"CompanyID = " & [CompanyID])
FROM tblCompany;

So add StateAbbr to your list in the Select statement.
Or
=ConcatRelated("StateAbbr","tblProdState","ProdID =" & [ProdID])

You use tblProdState. I'd substitute that with a query most likely.
I'd link the state table with tblProdState and be done with it. Ex:
=ConcatRelated("StateAbbr","qryProdState","ProdID =" & [ProdID])

It seems pretty basic, your problem. I suppose you can make it more
complicated than it is. Then again, I may not understand your problem.



You totally solved my problem!! I knew I had to be making it way
harder than it had to be.
So I created qryProdState from tblProdState. I added a field
Statelookup("State","qryProdState","StateID = " & [StateID])
Then, I put =ConcatRelated("State","qryProdState","ProdID =" &
[ProdID])

Sometimes, you just have to bounce it off someone to see things
clearly. I could have made a real mess of this one. Thanks!!

-WhathaveIdone?
Hmmm...the dlookup can make it slower. I figured you were getting a
mass of records for a record source. Anyway, do you have a States
table? If so, create a query and drop tblProdState and StateCodes to
it. You can use an inner join on StatesID but you can use a left join
if there's some recs without a state ID in the ProdState table. Then
drag the * from tblProdState and the state abbrv or state name to
another column. Like I said, that'd be faster than Dlookup and less
typing. Anyway, glad you have it figured out.

Reply With Quote
Reply




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 On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.