Group:  Microsoft Access ยป microsoft.public.access.formscoding
Thread: Get dates from table where month and year like txtbox

Geek News

Get dates from table where month and year like txtbox
Gator 11/14/2008 8:18:07 PM
I have a label control where I want to list all the dates that are like the
month and year that is displayed in a textbox (which gets it's date from a
calendar control), how would that be stated on form load?
something like....????


Dim text3 As Date
cal.Value = Date
text3 = cal.Value
Label8.Caption = DCount("DateDep", "Deposits", "Year([DateDep]) = " &
DatePart("y", Me![text3]) & " And Month([DateDep]) = " & DatePart("m",
Me![text3]) & "")

RE: Get dates from table where month and year like txtbox
Gator 11/14/2008 8:23:04 PM
I realize that DCount is probably not right....but I'm not sure what to use ?
Do I need a loop ?

"Gator" wrote:

[Quoted Text]
> I have a label control where I want to list all the dates that are like the
> month and year that is displayed in a textbox (which gets it's date from a
> calendar control), how would that be stated on form load?
> something like....????
>
>
> Dim text3 As Date
> cal.Value = Date
> text3 = cal.Value
> Label8.Caption = DCount("DateDep", "Deposits", "Year([DateDep]) = " &
> DatePart("y", Me![text3]) & " And Month([DateDep]) = " & DatePart("m",
> Me![text3]) & "")
>
RE: Get dates from table where month and year like txtbox
Beetle 11/14/2008 9:49:01 PM
You're not going to be able to do that with a label. Use a list box, then
you won't need any code other than one line to requery the list box
when the value in the text box is updated.
--
_________

Sean Bailey


"Gator" wrote:

[Quoted Text]
> I realize that DCount is probably not right....but I'm not sure what to use ?
> Do I need a loop ?
>
> "Gator" wrote:
>
> > I have a label control where I want to list all the dates that are like the
> > month and year that is displayed in a textbox (which gets it's date from a
> > calendar control), how would that be stated on form load?
> > something like....????
> >
> >
> > Dim text3 As Date
> > cal.Value = Date
> > text3 = cal.Value
> > Label8.Caption = DCount("DateDep", "Deposits", "Year([DateDep]) = " &
> > DatePart("y", Me![text3]) & " And Month([DateDep]) = " & DatePart("m",
> > Me![text3]) & "")
> >
RE: Get dates from table where month and year like txtbox
Gator 11/14/2008 10:22:00 PM
I did this instead...on click event...But it is not pulling any dates..???
List9.RowSource = "SELECT DISTINCT DateDep FROM Deposits WHERE
Year([DateDep])=" & Year([Text3]) & " And month([DateDep])=" & Month([Text3])
& ";"


"Beetle" wrote:

[Quoted Text]
> You're not going to be able to do that with a label. Use a list box, then
> you won't need any code other than one line to requery the list box
> when the value in the text box is updated.
> --
> _________
>
> Sean Bailey
>
>
> "Gator" wrote:
>
> > I realize that DCount is probably not right....but I'm not sure what to use ?
> > Do I need a loop ?
> >
> > "Gator" wrote:
> >
> > > I have a label control where I want to list all the dates that are like the
> > > month and year that is displayed in a textbox (which gets it's date from a
> > > calendar control), how would that be stated on form load?
> > > something like....????
> > >
> > >
> > > Dim text3 As Date
> > > cal.Value = Date
> > > text3 = cal.Value
> > > Label8.Caption = DCount("DateDep", "Deposits", "Year([DateDep]) = " &
> > > DatePart("y", Me![text3]) & " And Month([DateDep]) = " & DatePart("m",
> > > Me![text3]) & "")
> > >
RE: Get dates from table where month and year like txtbox
Gator 11/14/2008 10:31:01 PM
it works...thx

"Gator" wrote:

[Quoted Text]
> I did this instead...on click event...But it is not pulling any dates..???
> List9.RowSource = "SELECT DISTINCT DateDep FROM Deposits WHERE
> Year([DateDep])=" & Year([Text3]) & " And month([DateDep])=" & Month([Text3])
> & ";"
>
>
> "Beetle" wrote:
>
> > You're not going to be able to do that with a label. Use a list box, then
> > you won't need any code other than one line to requery the list box
> > when the value in the text box is updated.
> > --
> > _________
> >
> > Sean Bailey
> >
> >
> > "Gator" wrote:
> >
> > > I realize that DCount is probably not right....but I'm not sure what to use ?
> > > Do I need a loop ?
> > >
> > > "Gator" wrote:
> > >
> > > > I have a label control where I want to list all the dates that are like the
> > > > month and year that is displayed in a textbox (which gets it's date from a
> > > > calendar control), how would that be stated on form load?
> > > > something like....????
> > > >
> > > >
> > > > Dim text3 As Date
> > > > cal.Value = Date
> > > > text3 = cal.Value
> > > > Label8.Caption = DCount("DateDep", "Deposits", "Year([DateDep]) = " &
> > > > DatePart("y", Me![text3]) & " And Month([DateDep]) = " & DatePart("m",
> > > > Me![text3]) & "")
> > > >
RE: Get dates from table where month and year like txtbox
Beetle 11/14/2008 10:35:01 PM
If Text3 (which really should be renamed to something meaningful)
is an unbound control on your form, you might want to typecast it to
make sure it is interpreted as a date. Also, I wouldn't use the DISTINCT
predicate in this case;

"SELECT DateDep FROM Deposits WHERE Year([DateDep])="
& Year(CDate(Me![Text3])) & " And month([DateDep])=" &
Month(CDate(Me![Text3])) & ";"

--
_________

Sean Bailey


"Gator" wrote:

[Quoted Text]
> I did this instead...on click event...But it is not pulling any dates..???
> List9.RowSource = "SELECT DISTINCT DateDep FROM Deposits WHERE
> Year([DateDep])=" & Year([Text3]) & " And month([DateDep])=" & Month([Text3])
> & ";"
>
>
> "Beetle" wrote:
>
> > You're not going to be able to do that with a label. Use a list box, then
> > you won't need any code other than one line to requery the list box
> > when the value in the text box is updated.
> > --
> > _________
> >
> > Sean Bailey
> >
> >
> > "Gator" wrote:
> >
> > > I realize that DCount is probably not right....but I'm not sure what to use ?
> > > Do I need a loop ?
> > >
> > > "Gator" wrote:
> > >
> > > > I have a label control where I want to list all the dates that are like the
> > > > month and year that is displayed in a textbox (which gets it's date from a
> > > > calendar control), how would that be stated on form load?
> > > > something like....????
> > > >
> > > >
> > > > Dim text3 As Date
> > > > cal.Value = Date
> > > > text3 = cal.Value
> > > > Label8.Caption = DCount("DateDep", "Deposits", "Year([DateDep]) = " &
> > > > DatePart("y", Me![text3]) & " And Month([DateDep]) = " & DatePart("m",
> > > > Me![text3]) & "")
> > > >

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