dbTalk Databases Forums  

DLookup value not visible until clicked

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


Discuss DLookup value not visible until clicked in the comp.databases.ms-access forum.



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

Default DLookup value not visible until clicked - 07-27-2010 , 10:14 PM






I have a calculated field on a form with the following as its
controlsource.

=DLookUp("BupaID","Lookups_UserT","Category='Provi der number' AND
Details='" & [ProviderNumber] & "'")

This looks up a value in a lookup table based on another value in the
form. The [ProviderNumber] field is bound to the form's recordsource.

This works fine except that when the form is opened the value is not
visible in the field until you click on the field.

I can't work out how to get the value to appear automatically. I've
tried .requery and .repaint on the field and form to no avail.

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

Default Re: DLookup value not visible until clicked - 07-28-2010 , 12:34 AM






Owen wrote:

Quote:
I have a calculated field on a form with the following as its
controlsource.

=DLookUp("BupaID","Lookups_UserT","Category='Provi der number' AND
Details='" & [ProviderNumber] & "'")

This looks up a value in a lookup table based on another value in the
form. The [ProviderNumber] field is bound to the form's recordsource.

This works fine except that when the form is opened the value is not
visible in the field until you click on the field.

I can't work out how to get the value to appear automatically. I've
tried .requery and .repaint on the field and form to no avail.
What happens if you change it to
NZ([ProviderNumber],"")
since it's a text value?

What happens if the record exists and you enter
Me.CalcFieldName.Requery
in the onCurrent event. Or in the AfterUpdate event you enter a
Provider Number?

Reply With Quote
  #3  
Old   
paii, Ron
 
Posts: n/a

Default Re: DLookup value not visible until clicked - 07-28-2010 , 10:09 AM



Move the DLookUp to the form's on current event; fill the control with the
returned value.

DLookUp is very slow, you may want to replace it with eLookup. I use the one
from Allen Browne. abrowne1 (AT) bigpond (DOT) net.au

"Owen" <google (AT) healthbase (DOT) com.au> wrote

Quote:
I have a calculated field on a form with the following as its
controlsource.

=DLookUp("BupaID","Lookups_UserT","Category='Provi der number' AND
Details='" & [ProviderNumber] & "'")

This looks up a value in a lookup table based on another value in the
form. The [ProviderNumber] field is bound to the form's recordsource.

This works fine except that when the form is opened the value is not
visible in the field until you click on the field.

I can't work out how to get the value to appear automatically. I've
tried .requery and .repaint on the field and form to no avail.

Reply With Quote
  #4  
Old   
David W. Fenton
 
Posts: n/a

Default Re: DLookup value not visible until clicked - 07-28-2010 , 12:20 PM



Owen <google (AT) healthbase (DOT) com.au> wrote in
news:0da92a5f-323d-415d-9abb-4457b4eadadb (AT) v35g2000prn (DOT) googlegroups.co
m:

Quote:
I have a calculated field on a form with the following as its
controlsource.

=DLookUp("BupaID","Lookups_UserT","Category='Provi der number' AND
Details='" & [ProviderNumber] & "'")

This looks up a value in a lookup table based on another value in
the form. The [ProviderNumber] field is bound to the form's
recordsource.
Is there some reason you can't just put the lookup table in the
form's recordsource and retrieve the value along with the main
record?

I'm always suspicious of DLookup() as it is very seldom the case
that the value cannot be retrieved in the form's/report's
recordsource (though sometimes that can cause updatability problems,
so it's not always a mistake).

--
David W. Fenton http://www.dfenton.com/
contact via website only http://www.dfenton.com/DFA/

Reply With Quote
  #5  
Old   
Phil
 
Posts: n/a

Default Re: DLookup value not visible until clicked - 07-28-2010 , 04:07 PM



On 28/07/2010 16:09:33, "paii, Ron" wrote:
Quote:
Move the DLookUp to the form's on current event; fill the control with the
returned value.

DLookUp is very slow, you may want to replace it with eLookup. I use the
one from Allen Browne. abrowne1 (AT) bigpond (DOT) net.au

"Owen" <google (AT) healthbase (DOT) com.au> wrote in message
news:0da92a5f-323d-415d-9abb-4457b4eadadb (AT) v35g2000prn (DOT) googlegroups.com...
I have a calculated field on a form with the following as its
controlsource.

=DLookUp("BupaID","Lookups_UserT","Category='Provi der number' AND
Details='" & [ProviderNumber] & "'")

This looks up a value in a lookup table based on another value in the
form. The [ProviderNumber] field is bound to the form's recordsource.

This works fine except that when the form is opened the value is not
visible in the field until you click on the field.

I can't work out how to get the value to appear automatically. I've
tried .requery and .repaint on the field and form to no avail.


I always use Elookup instead of Dlookup as well as EMax, EMin etc. I tried to
test the difference in speed in AK2 some time ago and found very little
difference. Almost certainly wrong, but could this be a myth?

Phil

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

Default Re: DLookup value not visible until clicked - 07-28-2010 , 08:32 PM



Thanks for all the responses.

Salad - Nz() makes no difference.
Requery makes no difference.

Ron - moving DLookup to the Current event worked. Thanks.
Thanks for the eLookup tip.

David - using the lookup value in the recordsource renders the form
data uneditable.

Phil - thanks, I'll look at using eLookup in future.

I'm still mystified as to why the calc field would not display the
value, since it is there when you click the field. But I'll go with
Ron's method to get around it.

Thanks all.
Owen

Reply With Quote
  #7  
Old   
Phil
 
Posts: n/a

Default Re: DLookup value not visible until clicked - 07-29-2010 , 03:26 AM



On 29/07/2010 02:32:21, Owen wrote:
Quote:
Thanks for all the responses.

Salad - Nz() makes no difference.
Requery makes no difference.

Ron - moving DLookup to the Current event worked. Thanks.
Thanks for the eLookup tip.

David - using the lookup value in the recordsource renders the form
data uneditable.

Phil - thanks, I'll look at using eLookup in future.

I'm still mystified as to why the calc field would not display the
value, since it is there when you click the field. But I'll go with
Ron's method to get around it.

Thanks all.
Owen

I,m having problems with the structure of your Lookups_UserT table. Do you
have 2 fields Category and details both text? You alst refer to both
'Provider number' and 'ProviderNumber' , presumably on the form. What sort of
data are they - text or numeric?

Phil

Reply With Quote
  #8  
Old   
John Spencer
 
Posts: n/a

Default Re: DLookup value not visible until clicked - 07-29-2010 , 07:10 AM



RESPONDING TO "...could this be a myth?"

The domain functions (DLookup, DMax, DMin, etc.) are relatively slow, but you
only notice the "slowness" when you are calling them multiple times in a loop
of some kind. Or if you are calling them in a query and returning a lot of
records or are filtering on the result of the function call.

For one record I doubt that you could detect much difference (if any) between
Allen Browne's functions and the built-in functions. The enhanced abilities
of Allen's functions are of real benefit and the use of the enhanced abilities
might (I've not tested this) actually make them a bit slower.

John Spencer
Access MVP 2002-2005, 2007-2010
The Hilltop Institute
University of Maryland Baltimore County

Quote:
I always use Elookup instead of Dlookup as well as EMax, EMin etc. I tried to
test the difference in speed in AK2 some time ago and found very little
difference. Almost certainly wrong, but could this be a myth?

Phil

Reply With Quote
  #9  
Old   
paii, Ron
 
Posts: n/a

Default Re: DLookup value not visible until clicked - 07-29-2010 , 07:17 AM



"John Spencer" <JSPENCER (AT) Hilltop (DOT) umbc> wrote

Quote:
RESPONDING TO "...could this be a myth?"

The domain functions (DLookup, DMax, DMin, etc.) are relatively slow, but
you
only notice the "slowness" when you are calling them multiple times in a
loop
of some kind. Or if you are calling them in a query and returning a lot
of
records or are filtering on the result of the function call.

For one record I doubt that you could detect much difference (if any)
between
Allen Browne's functions and the built-in functions. The enhanced
abilities
of Allen's functions are of real benefit and the use of the enhanced
abilities
might (I've not tested this) actually make them a bit slower.

John Spencer
Access MVP 2002-2005, 2007-2010
The Hilltop Institute
University of Maryland Baltimore County

I always use Elookup instead of Dlookup as well as EMax, EMin etc. I
tried to
test the difference in speed in AK2 some time ago and found very little
difference. Almost certainly wrong, but could this be a myth?

Phil
In this case the OP appears to be calling the dlookup function for each
record on the form. elookup will show a noticeable improvement in displaying
the next record.

Reply With Quote
  #10  
Old   
paii, Ron
 
Posts: n/a

Default Re: DLookup value not visible until clicked - 07-29-2010 , 07:21 AM



"Owen" <google (AT) healthbase (DOT) com.au> wrote

Quote:
Thanks for all the responses.

Salad - Nz() makes no difference.
Requery makes no difference.

Ron - moving DLookup to the Current event worked. Thanks.
Thanks for the eLookup tip.

David - using the lookup value in the recordsource renders the form
data uneditable.

Phil - thanks, I'll look at using eLookup in future.

I'm still mystified as to why the calc field would not display the
value, since it is there when you click the field. But I'll go with
Ron's method to get around it.

Thanks all.
Owen
I think Access attempts to save time by only refreshing controls it thinks
changed. In your case the row source being a function appears to Access as
static.

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.