Textbox display month and year with buttons

Thanks you guys, still stuck on one bit though. I want the form to load with the current month and year in the text box. How do I get that to display and still use the commanf buttons to change the month as I can either get one or the others to work
 
Click on your form and have a look at the events of the form. See if one of the events matches your need.
 
and now I get a run time error 13 with the buttons
 
I think I know what is was, the command button was looking for data already in the textbox but there was none. So I placed

monthtext = Format(Date(),"mmmm yy")

as On Load Event and it worked fine.

Thanks for your help, can I use the textbox to filter the results that are displayed now in other forms
 
...can I use the textbox to filter the results that are displayed now in other forms

Yes, you can. You just have to refer to it like


Forms!YourFormName.YourControlName

or if on a subform

Forms!YourMainFormName.SubformControlName.Form.YourControlName

where the subformcontrolname is the name of the control on the main form which houses the subform, not the subform itself. Unless the subformcontrolname and the subform are named the same and then you can use the subform name. The .Form. part stays in so Access knows you want something on the subform and not the subformcontrol.
 
yes the monthtext is on form MainMenu

how do I add it to

oCmd.OpenForm "P1list" ,,

P1list is the form I need to filter the data
 
ok I have

DoCmd.OpenForm "P1list", , Forms!MainMenu.monthtext

but it doesnt filter the data
 
DoCmd.OpenForm "P1list", acNormal, , "[FieldNameOnP1List]=" & Chr(34) & Forms!MainMenu.monthtext & Chr(34)


And you need to put in your correct field name on P1list that I have as FieldNameOnP1List so that it filters by that field.
 
i got an error

Well, are you going to share what it was or do we have to guess from the 50,000 possible error messages that Access can give?
 
Run-time eroor 2501

The openform action was canceled

You used a mothod of the DCmd object to carry out an action in Visual Basic, but then clicked Cancel in a dialog box, For example, you used the Close mehtod to close a changed for, then clicked cancel...............


Oi give me chance
 
What it is doing is it can't find either the field you set in the code (so perhaps you should post what you actually used) or the other form was not left open so it could get the value.
 
DoCmd.OpenForm "P1list", acNormal, , "[DateOfWork]=" & Chr(34) & Forms!MainMenu.monthtext & Chr(34)

sorry
 
Code:
DoCmd.OpenForm "P1list", acNormal, , "[DateOfWork]=#" & Forms!MainMenu.monthtext & "#"

For dates you wrap them in hash characters and remember to close your paramter with another quote. See above.
 
does it help if i tell you guys the textbox is eg. march 10 and the field value 14/03/2010
 

Users who are viewing this thread

Back
Top Bottom