Re: Dlookup with 2 criteria
- From: "Michelle K" <MichelleK@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Tue, 19 Jul 2005 09:43:02 -0700
Thanks. both of them are text fields. how should i change my code?
"Marshall Barton" wrote:
> Michelle K wrote:
> >I am trying to prefill a textbox (txtBudget) with the budget value found in
> >the testquery table. I have two criteria : cost code and category which are
> >both filled in using combo boxes (cboCC and cboCat).
> >
> >I'm trying the cboCat afterupdate procedure to update the textbox but my
> >code isn't working. help! thanks a lot.
> >
> >here is the code:
> >
> >Private Sub cboCat_AfterUpdate()
> >
> >Dim CC As String
> >Dim Cat As String
> >Dim result
> >
> >CC = cboCC.Value
> >Cat = cboCat.Value
> >
> >result = DLookup("[Total_Estimate]", "[testquery]", "[Cost_Code]= ' " & CC &
> >" ' and [Category] = " & Cat)
> >
> >txtBudget.Value = result
> >End Sub
>
>
> Apparently the Cost_Code field is a text field and Category
> is a numeric field. If that true, then the only thing I see
> wrong is the extra spaces between the quotes and
> apostrophes.
>
> To avoid potential errors, you may want to add more code to
> check that the two combo boxes actually have a value:
>
> If Nz(Me.cboCC, "") = "" OR Nz(cboCat, "") = "" Then
> Exit Sub
> End If
>
> --
> Marsh
> MVP [MS Access]
>
.
- Follow-Ups:
- Re: Dlookup with 2 criteria
- From: Klatuu
- Re: Dlookup with 2 criteria
- References:
- Dlookup with 2 criteria
- From: Michelle K
- Re: Dlookup with 2 criteria
- From: Marshall Barton
- Dlookup with 2 criteria
- Prev by Date: Re: Calling a Sub-routine in a Private Module
- Next by Date: Re: Please help speed up this process
- Previous by thread: Re: Dlookup with 2 criteria
- Next by thread: Re: Dlookup with 2 criteria
- Index(es):
Relevant Pages
|
|