Main Page | Report this Page
Computers Forum Index  »  Computer - Databases - MS Access  »  Dlookup structure problem?...
Page 1 of 1    

Dlookup structure problem?...

Author Message
emanning...
Posted: Thu Oct 29, 2009 7:48 pm
Guest
Using A2003. I'm using the coding below to look up AmountReceived for
a certain date:

strExpr = "AmountReceived"
strDomain = "qsel_rptFinancial_RegistrationDateAnalysis"
strCriteria = "RegistrationDate = #" & Me.txtRegistrationDate &
"#"
Me.txtAmountReceived = Nz(DLookup(strExpr, strDomain,
strCriteria), 0)

My first problem is that I get prompted for AmountReceived. The
domain is a query and I've verified that the column is in the query
and that it's spelled correctly. I've verified that RegistrationDate
is a valid date.

The second problem is that I get a message that a value cannot be
assigned to Me.txtAmountReceived. I assume I get this message because
it can't find AmountReceived.

I went to the immediate window and entered this:

? dlookup
("AmountReceived","qsel_rptFinancial_RegistrationDateAnalysis","RegistrationDate
= #2/6/2007#")

This returned a value like I expected it to.

Just before the above code, I have another dlookup that works just
fine. This is it:

strExpr = "MeetingStartDate"
strDomain = "tblMeetings"
strCriteria = "MeetingCode = " & conQuote & frm!cboMeetingCodes &
conQuote
datMeetingStartDate = Nz(DLookup(strExpr, strDomain, strCriteria),
"")

So my question is, what am I doing wrong with the first dlookup? Am I
just overlooking something? Thanks for any help or advice.
 
Allen Browne...
Posted: Fri Oct 30, 2009 3:31 am
Guest
Is there a field named AmountReceived in
qsel_rptFinancial_RegistrationDateAnalysis? The fact that you're asked for
parameter suggests that Access can't find this name in the query.

Check that txtRegistrationDate does contain a date (e.g. it's not null).
This kind of thing:
If IsDate(Me.txtRegistrationDate) Then
...

If the user's computer might not be in US date format, be explicit about the
format JET expects:
strCriteria = "RegistrationDate = #" & Format(Me.txtRegistrationDate,
"mm\/dd\/yyyy") & "#"

Use the Immediate Window (Ctrl+G) to ensure your variables contain what you
expected, e.g.
Debut.Print strCriteria

Return the result to a variable, so you can test what you get, before you
try to assign it to the text box, e.g.:
dim varResult As Variant
varResult = DLookup(...
If IsDate(varResult) Then ...

To solve the issue of not being able to assign a value to txtAmountReceived,
consider:
a) What is it? Text box? Label or something else?
b) Is it bound to an expression?
c) If bound to a field, is it a date/time field?

HTH

--
Allen Browne - Microsoft MVP. Perth, Western Australia
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.


"emanning" <emanning at (no spam) kumc.edu> wrote in message
news:1e951809-76e5-4fd3-9e3a-234475e45f59 at (no spam) k17g2000yqh.googlegroups.com...
Quote:
Using A2003. I'm using the coding below to look up AmountReceived for
a certain date:

strExpr = "AmountReceived"
strDomain = "qsel_rptFinancial_RegistrationDateAnalysis"
strCriteria = "RegistrationDate = #" & Me.txtRegistrationDate &
"#"
Me.txtAmountReceived = Nz(DLookup(strExpr, strDomain,
strCriteria), 0)

My first problem is that I get prompted for AmountReceived. The
domain is a query and I've verified that the column is in the query
and that it's spelled correctly. I've verified that RegistrationDate
is a valid date.

The second problem is that I get a message that a value cannot be
assigned to Me.txtAmountReceived. I assume I get this message because
it can't find AmountReceived.

I went to the immediate window and entered this:

? dlookup
("AmountReceived","qsel_rptFinancial_RegistrationDateAnalysis","RegistrationDate
= #2/6/2007#")

This returned a value like I expected it to.

Just before the above code, I have another dlookup that works just
fine. This is it:

strExpr = "MeetingStartDate"
strDomain = "tblMeetings"
strCriteria = "MeetingCode = " & conQuote & frm!cboMeetingCodes &
conQuote
datMeetingStartDate = Nz(DLookup(strExpr, strDomain, strCriteria),
"")

So my question is, what am I doing wrong with the first dlookup? Am I
just overlooking something? Thanks for any help or advice.
 
emanning...
Posted: Fri Oct 30, 2009 3:13 pm
Guest
On Oct 29, 6:31 pm, "Allen Browne" <AllenBro... at (no spam) SeeSig.invalid> wrote:
Quote:
Is there a field named AmountReceived in
qsel_rptFinancial_RegistrationDateAnalysis? The fact that you're asked for
parameter suggests that Access can't find this name in the query.

Check that txtRegistrationDate does contain a date (e.g. it's not null).
This kind of thing:
    If IsDate(Me.txtRegistrationDate) Then
        ...

If the user's computer might not be in US date format, be explicit about the
format JET expects:
    strCriteria = "RegistrationDate = #" & Format(Me.txtRegistrationDate,
"mm\/dd\/yyyy") & "#"

Use the Immediate Window (Ctrl+G) to ensure your variables contain what you
expected, e.g.
    Debut.Print strCriteria

Return the result to a variable, so you can test what you get, before you
try to assign it to the text box, e.g.:
    dim varResult As Variant
    varResult = DLookup(...
    If IsDate(varResult) Then ...

To solve the issue of not being able to assign a value to txtAmountReceived,
consider:
a) What is it? Text box? Label or something else?
b) Is it bound to an expression?
c) If bound to a field, is it a date/time field?

HTH

--
Allen Browne - Microsoft MVP.  Perth, Western Australia
Tips for Access users -http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"emanning" <emann... at (no spam) kumc.edu> wrote in message

news:1e951809-76e5-4fd3-9e3a-234475e45f59 at (no spam) k17g2000yqh.googlegroups.com...



Using A2003.  I'm using the coding below to look up AmountReceived for
a certain date:

   strExpr = "AmountReceived"
   strDomain = "qsel_rptFinancial_RegistrationDateAnalysis"
   strCriteria = "RegistrationDate = #" & Me.txtRegistrationDate &
"#"
   Me.txtAmountReceived = Nz(DLookup(strExpr, strDomain,
strCriteria), 0)

My first problem is that I get prompted for AmountReceived.  The
domain is a query and I've verified that the column is in the query
and that it's spelled correctly.  I've verified that RegistrationDate
is a valid date.

The second problem is that I get a message that a value cannot be
assigned to Me.txtAmountReceived.  I assume I get this message because
it can't find AmountReceived.

I went to the immediate window and entered this:

   ? dlookup
("AmountReceived","qsel_rptFinancial_RegistrationDateAnalysis","Registratio­nDate
= #2/6/2007#")

This returned a value like I expected it to.

Just before the above code, I have another dlookup that works just
fine.  This is it:

   strExpr = "MeetingStartDate"
   strDomain = "tblMeetings"
   strCriteria = "MeetingCode = " & conQuote & frm!cboMeetingCodes &
conQuote
   datMeetingStartDate = Nz(DLookup(strExpr, strDomain, strCriteria),
"")

So my question is, what am I doing wrong with the first dlookup?  Am I
just overlooking something?  Thanks for any help or advice.- Hide quoted text -

- Show quoted text -

Thanks for your reply. A stupid error on my part. I had a field
bound to AmountReceived but AmountReceived is not a column in the
recordsource, only in that query. After fixing that, then the dlookup
worked fine.
 
 
Page 1 of 1    
All times are GMT
The time now is Wed Dec 09, 2009 7:49 pm