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