Group:  Microsoft Access ยป microsoft.public.access.formscoding
Thread: Why won't this work?

Geek News

Why won't this work?
Gator 11/14/2008 4:28:01 PM
Private Sub Command2_Click()

Dim tot As Integer

tot = DCount("*", "Deposits", "DateDep")
Text3.Text = tot

End Sub

RE: Why won't this work?
Gator 11/14/2008 4:37:52 PM
or this????

Private Sub Command2_Click()

Dim tot As Integer

tot = DCount("*", "Deposits", "DateDep=#10/31/08#")
Text3.Text = tot

End Sub



"Gator" wrote:

[Quoted Text]
> Private Sub Command2_Click()
>
> Dim tot As Integer
>
> tot = DCount("*", "Deposits", "DateDep")
> Text3.Text = tot
>
> End Sub
>
Re: Why won't this work?
"Ken Snell \(MVP\)" <kthsneisllis9[ at ]ncoomcastt.renaetl> 11/14/2008 4:40:14 PM
What is Text3? What kind of object? Are you trying to set the value of a
field that is in the form's recordsource query or table? More details
please.

--

Ken Snell
<MS ACCESS MVP>
http://www.accessmvp.com/KDSnell/


"Gator" <Gator[ at ]discussions.microsoft.com> wrote in message
news:06F1069F-8F40-4046-B66C-433CF2DBF4FF[ at ]microsoft.com...
[Quoted Text]
> Private Sub Command2_Click()
>
> Dim tot As Integer
>
> tot = DCount("*", "Deposits", "DateDep")
> Text3.Text = tot
>
> End Sub
>


Re: Why won't this work?
Gator 11/14/2008 4:47:01 PM
just trying to provide an area where I can display the number of records from
a table in the DB....

"Ken Snell (MVP)" wrote:

[Quoted Text]
> What is Text3? What kind of object? Are you trying to set the value of a
> field that is in the form's recordsource query or table? More details
> please.
>
> --
>
> Ken Snell
> <MS ACCESS MVP>
> http://www.accessmvp.com/KDSnell/
>
>
> "Gator" <Gator[ at ]discussions.microsoft.com> wrote in message
> news:06F1069F-8F40-4046-B66C-433CF2DBF4FF[ at ]microsoft.com...
> > Private Sub Command2_Click()
> >
> > Dim tot As Integer
> >
> > tot = DCount("*", "Deposits", "DateDep")
> > Text3.Text = tot
> >
> > End Sub
> >
>
>
>
Re: Why won't this work?
"Klatuu" <david.hargis[ at ]realpage.com> 11/14/2008 5:00:47 PM
Leave off the .Text
It is valid only when the control has the focus. It really is more of a
holdover from Classic VB.

In VBA, Me.Text3 is sufficient (other than the name is meaningless and gives
no clue as to its use).

"Gator" <Gator[ at ]discussions.microsoft.com> wrote in message
news:006321A6-DD2C-4441-BD79-237A942CCF84[ at ]microsoft.com...
[Quoted Text]
> just trying to provide an area where I can display the number of records
> from
> a table in the DB....
>
> "Ken Snell (MVP)" wrote:
>
>> What is Text3? What kind of object? Are you trying to set the value of a
>> field that is in the form's recordsource query or table? More details
>> please.
>>
>> --
>>
>> Ken Snell
>> <MS ACCESS MVP>
>> http://www.accessmvp.com/KDSnell/
>>
>>
>> "Gator" <Gator[ at ]discussions.microsoft.com> wrote in message
>> news:06F1069F-8F40-4046-B66C-433CF2DBF4FF[ at ]microsoft.com...
>> > Private Sub Command2_Click()
>> >
>> > Dim tot As Integer
>> >
>> > tot = DCount("*", "Deposits", "DateDep")
>> > Text3.Text = tot
>> >
>> > End Sub
>> >
>>
>>
>>


Re: Why won't this work?
"Douglas J. Steele" <NOSPAM_djsteele[ at ]NOSPAM_gmail.com> 11/14/2008 5:01:53 PM
What does not working mean? Are you getting an error? If so, what's the
error? If you're not getting an error, what are you getting, and what do you
want to get instead?

The first one didn't work because the Where condition was invalid. This one,
though, is syntactically correct.

Note that there's no reason to use tot. The following should be sufficient:

Private Sub Command2_Click()

Text3.Text = DCount("*", "Deposits", "DateDep=#10/31/08#")

End Sub


--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)


"Gator" <Gator[ at ]discussions.microsoft.com> wrote in message
news:96C9D5EE-2EDF-4AE6-BE0B-765E1305F971[ at ]microsoft.com...
[Quoted Text]
> or this????
>
> Private Sub Command2_Click()
>
> Dim tot As Integer
>
> tot = DCount("*", "Deposits", "DateDep=#10/31/08#")
> Text3.Text = tot
>
> End Sub
>
>
>
> "Gator" wrote:
>
>> Private Sub Command2_Click()
>>
>> Dim tot As Integer
>>
>> tot = DCount("*", "Deposits", "DateDep")
>> Text3.Text = tot
>>
>> End Sub
>>


Re: Why won't this work?
"Klatuu" <david.hargis[ at ]realpage.com> 11/14/2008 5:08:23 PM
Still wont work, Doug.
Text3 doesn't have the focus.

"Douglas J. Steele" <NOSPAM_djsteele[ at ]NOSPAM_gmail.com> wrote in message
news:%23olIzqnRJHA.4764[ at ]TK2MSFTNGP05.phx.gbl...
[Quoted Text]
> What does not working mean? Are you getting an error? If so, what's the
> error? If you're not getting an error, what are you getting, and what do
> you want to get instead?
>
> The first one didn't work because the Where condition was invalid. This
> one, though, is syntactically correct.
>
> Note that there's no reason to use tot. The following should be
> sufficient:
>
> Private Sub Command2_Click()
>
> Text3.Text = DCount("*", "Deposits", "DateDep=#10/31/08#")
>
> End Sub
>
>
> --
> Doug Steele, Microsoft Access MVP
> http://I.Am/DougSteele
> (no e-mails, please!)
>
>
> "Gator" <Gator[ at ]discussions.microsoft.com> wrote in message
> news:96C9D5EE-2EDF-4AE6-BE0B-765E1305F971[ at ]microsoft.com...
>> or this????
>>
>> Private Sub Command2_Click()
>>
>> Dim tot As Integer
>>
>> tot = DCount("*", "Deposits", "DateDep=#10/31/08#")
>> Text3.Text = tot
>>
>> End Sub
>>
>>
>>
>> "Gator" wrote:
>>
>>> Private Sub Command2_Click()
>>>
>>> Dim tot As Integer
>>>
>>> tot = DCount("*", "Deposits", "DateDep")
>>> Text3.Text = tot
>>>
>>> End Sub
>>>
>
>


Re: Why won't this work?
"Douglas J. Steele" <NOSPAM_djsteele[ at ]NOSPAM_gmail.com> 11/14/2008 5:41:53 PM
Damn. It's the little details that catch you up each time! <g>

Thanks, Dave.

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)


"Klatuu" <david.hargis[ at ]realpage.com> wrote in message
news:ehLObunRJHA.5976[ at ]TK2MSFTNGP05.phx.gbl...
[Quoted Text]
> Still wont work, Doug.
> Text3 doesn't have the focus.
>
> "Douglas J. Steele" <NOSPAM_djsteele[ at ]NOSPAM_gmail.com> wrote in message
> news:%23olIzqnRJHA.4764[ at ]TK2MSFTNGP05.phx.gbl...
>> What does not working mean? Are you getting an error? If so, what's the
>> error? If you're not getting an error, what are you getting, and what do
>> you want to get instead?
>>
>> The first one didn't work because the Where condition was invalid. This
>> one, though, is syntactically correct.
>>
>> Note that there's no reason to use tot. The following should be
>> sufficient:
>>
>> Private Sub Command2_Click()
>>
>> Text3.Text = DCount("*", "Deposits", "DateDep=#10/31/08#")
>>
>> End Sub
>>
>>
>> --
>> Doug Steele, Microsoft Access MVP
>> http://I.Am/DougSteele
>> (no e-mails, please!)
>>
>>
>> "Gator" <Gator[ at ]discussions.microsoft.com> wrote in message
>> news:96C9D5EE-2EDF-4AE6-BE0B-765E1305F971[ at ]microsoft.com...
>>> or this????
>>>
>>> Private Sub Command2_Click()
>>>
>>> Dim tot As Integer
>>>
>>> tot = DCount("*", "Deposits", "DateDep=#10/31/08#")
>>> Text3.Text = tot
>>>
>>> End Sub
>>>
>>>
>>>
>>> "Gator" wrote:
>>>
>>>> Private Sub Command2_Click()
>>>>
>>>> Dim tot As Integer
>>>>
>>>> tot = DCount("*", "Deposits", "DateDep")
>>>> Text3.Text = tot
>>>>
>>>> End Sub
>>>>
>>
>>
>
>


Re: Why won't this work?
John W. Vinson <jvinson[ at ]STOP_SPAM.WysardOfInfo.com> 11/14/2008 7:03:21 PM
On Fri, 14 Nov 2008 08:47:01 -0800, Gator <Gator[ at ]discussions.microsoft.com>
wrote:

[Quoted Text]
>just trying to provide an area where I can display the number of records from
>a table in the DB....

Don't use any VBA code AT ALL then; instead set the Control Source of Text3
(or rename the control to txtRecordCount if you want to preserve your sanity
when you revisit this database in six months) to

=DCount("*", "Deposits")

If you want the number of deposits on a particular date, you'll need to add a
third parameter to the DCount - just putting in DateDep won't work, because
the third argument needs to be a valid SQL WHERE clause. For today's date you
could use

=DCount("*", "Deposits", "[DateDep] = #" & Date() & "#")

but it's not clear what records you want to count!
--

John W. Vinson [MVP]
Re: Why won't this work?
Gator 11/14/2008 7:42:07 PM
all records....just trying to get the number of records in a table.

"John W. Vinson" wrote:

[Quoted Text]
> On Fri, 14 Nov 2008 08:47:01 -0800, Gator <Gator[ at ]discussions.microsoft.com>
> wrote:
>
> >just trying to provide an area where I can display the number of records from
> >a table in the DB....
>
> Don't use any VBA code AT ALL then; instead set the Control Source of Text3
> (or rename the control to txtRecordCount if you want to preserve your sanity
> when you revisit this database in six months) to
>
> =DCount("*", "Deposits")
>
> If you want the number of deposits on a particular date, you'll need to add a
> third parameter to the DCount - just putting in DateDep won't work, because
> the third argument needs to be a valid SQL WHERE clause. For today's date you
> could use
>
> =DCount("*", "Deposits", "[DateDep] = #" & Date() & "#")
>
> but it's not clear what records you want to count!
> --
>
> John W. Vinson [MVP]
>
Re: Why won't this work?
John W. Vinson <jvinson[ at ]STOP_SPAM.WysardOfInfo.com> 11/15/2008 5:10:35 AM
On Fri, 14 Nov 2008 11:42:07 -0800, Gator <Gator[ at ]discussions.microsoft.com>
wrote:

[Quoted Text]
>all records....just trying to get the number of records in a table.
>

In that case I'll reiterate:

Don't use any VBA code AT ALL then; instead set the Control Source of Text3
(or rename the control to txtRecordCount if you want to preserve your sanity
when you revisit this database in six months) to

=DCount("*", "Deposits")

--

John W. Vinson [MVP]

Home | Search | Terms | Imprint Contact
Newsgroups Reader - provided by WiredBox.Net