Re: Better Way?

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



Thanks for the time!

One question, when I complie I get "Compile Error: Syntax error" on line
If IsNull(DLookup("[Rate]", "tbl_Tonnage_Rate", StrCriteria) Then

Do you know why?

Thanks again!
Stacey

"Ronald W. Roberts" wrote:

> SMac wrote:
>
> >How would I write the DLookup?
> >Thanks!
> >
> >"1" wrote:
> >
> >
> >
> >>On Mon, 25 Apr 2005 08:51:01 -0700, "SMac"
> >><SMac@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote:
> >>
> >>(snip)
> >>
> >>
> >>>It seems so easy in thought but to write code I am lost how to make 2
> >>>criterias before the "Then" section of an If-Then statement.
> >>>
> >>>Thanks!!
> >>>Stacey
> >>>
> >>>
> >>Im not sure why you need an If,Then for this, I would think its a
> >>straightforward Dlookup
> >>
> >>To answer the question:
> >>
> >>If (Condition1=True) and (condition2 = True) then Goto ...
> >>
> >>it could also be "or"
> >>
> >>
> >>
> >>
> This is air code, but it will be something like this.
>
> Dim MyRate As Currency
> Dim StrCriteria as String
>
> StrCriteria="Model_Year =" & Me!Model_Year
> StrCriteria = StrCriteria & " Tonnage_Start <=" & Me!Rate
> StrCriteria = strCriteria & " And Tonnage_Finish >=" & Me!Rate
> If IsNull(DLookup("[Rate]", "tbl_Tonnage_Rate", StrCriteria) Then
> MyRate = 0
> Else
> MyRate = DLookup("[Rate]", "tbl_Tonnage_Rate", StrCriteria)
> EndIF
>
> Me!Rate and Me!Model_Year are the control names on the form.
>
> Ron
>
> --
> Ronald W. Roberts
> Roberts Communication
> rwr@xxxxxxxxxx
>
>
.



Relevant Pages

  • Re: Better Way?
    ... "Ronald W. Roberts" wrote: ... >>How would I write the DLookup? ... > Dim MyRate As Currency ...
    (microsoft.public.access.formscoding)
  • Re: Suppress a line of print
    ... Ronald W. Roberts wrote: ... > I want to suppress 1 line of print in a group heading if there is no ...
    (microsoft.public.access.reports)
  • Re: Prompting a user for file name on import
    ... This code is a new feature in Access 2002. ... It allows you to browse for a file and then store the selected file in 2 ... "Ronald W. Roberts" wrote in message ...
    (microsoft.public.access.externaldata)
  • Re: How to using to 2 condition with Dsum
    ... I could see it if you were using a DCount. ... Ron ... Ronald W. Roberts ...
    (microsoft.public.access.formscoding)