Get dates from table where month and year like txtbox

G

Gator

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]) & "")
 
G

Gator

I realize that DCount is probably not right....but I'm not sure what to use ?
Do I need a loop ?
 
B

Beetle

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 said:
I realize that DCount is probably not right....but I'm not sure what to use ?
Do I need a loop ?

Gator said:
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]) & "")
 
G

Gator

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 said:
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 said:
I realize that DCount is probably not right....but I'm not sure what to use ?
Do I need a loop ?

Gator said:
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]) & "")
 
G

Gator

it works...thx

Gator said:
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 said:
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 said:
I realize that DCount is probably not right....but I'm not sure what to use ?
Do I need a loop ?

:

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]) & "")
 
B

Beetle

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 said:
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 said:
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 said:
I realize that DCount is probably not right....but I'm not sure what to use ?
Do I need a loop ?

:

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]) & "")
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top