Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

vba questions-- date and subforms 2

Status
Not open for further replies.

InsaneMember

Technical User
Apr 24, 2002
16
0
0
US
okay... if i was going to use .recordsource, can it be on a bound sub-form, or does it have to be on an unbound sub-form?

also,

how do we find the last DATE of the month. (ie is it the 29th? 30th? 31?)
 
Start from back to front:

Function LastDay(dtm as Date) As Date

LastDay=dateserial(year(dtm),month(dtm)+1,1)-1

end Function

osla

AFAIK you can set the recordsource of any type of form, bound or not.

just do it!

B ----------------------------------
Ben O'Hara
Home: bpo@RobotParade.co.uk
Work: bo104@westyorkshire.pnn.police.uk
Web: ----------------------------------
 
i get this "method not found" error when i do a subform.recordsource = sqlstring

also... according to that function, i would have to have a date put into it. would it work if i just went something like month(august) or something like that?
 
Hi!

A subform is not in the Forms collection so you can't refer to it like a main form. If the code is in the subform then you should be able to use Me.Recordsource etc. If the code is in the main form, or a module etc., then use this to reference the subform: Forms!MainForm!SubForm.Form.RecordSource.

hth
Jeff Bridgham
bridgham@purdue.edu
 
i'm sorry... this is still confusion...
okay, say i have a main form named Legs and a subform named Hips, it would look like this:

Forms!Legs!Hips!Hips.RecordSource

?
 
Hi!

No, it would be Forms!Legs!Hips.Form.RecordSource.

hth
Jeff Bridgham
bridgham@purdue.edu
 
THANKS! that segment works now... now nothing is turning up on my query... and there's this weird thing that i get a "type mismatch" error every so often, even if i haven't changed any of the input. Could someone straighten me out?

Function FilterMonth()
Dim PayPeriodStart, PayPeriodEnd As String
Dim Store As String
PayPeriodStart = CStr(DateValue(cmbMth.Value + " " + CStr(begDate) + ", " + cmbYear.Value))
PayPeriodEnd = CStr(DateValue(cmbMth.Value + " " + CStr(lasDate) + ", " + cmbYear.Value))
Store = &quot;SELECT * FROM [Calc Hours] WHERE [Date] > #&quot; + PayPeriodStart + &quot;# AND [Date] < #&quot; + PayPeriodEnd + &quot;#&quot;
Forms![Employee Hours]![Calc Hours subform].Form.RecordSource = Store
[Calc Hours subform].Requery

End Function
 
hmm... i got the code to work... sort of... it runs the query only when i've gone through the combo boxes, like twice. also if the combo boxes are empty; it gives me a null error (null value invalid or something like that)

is there some way to input default values when the form first starts?

i remembered in vb there was this
sub form_intialize
is it like that too in vb access or is it something else?

oh yeah, WHY is my query not showing the first of the month? (it shows the 2nd, 3rd, 4th, etc. until the 31, but not the 1st)


heeeeeeeeeeeeellllpp!! someone help this pathetic n00b
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top