OpenArgs Possible question

  • Thread starter Thread starter blake7
  • Start date Start date
B

blake7

Hi , is it possible to write code behind a button for something to happen in
another form, i have a form (Issue Count1) with a graph, the graph is linked
to a select query, i am running the open form from a command button in
another menu screen(view graph) , the graph simply displays the data i want and it works fine. It is displaying issues between two dates, I have a series of
twelve command buttons, one for each month and would like the command button
when pressed to place the current month at the top of the form (Issues
count1) in a text field. The code behind the button is as follows: Thanks
Tony. hope you understand !!
 
Hi , is it possible to write code behind a button for something to happen in
twelve command buttons, one for each month and would like the command button
when pressed to place the current month at the top of the form (Issues
count1) in a text field. The code behind the button is as follows: Thanks
Tony. hope you understand !!

I'd use a quite different approach: you don't need OpenArgs at all, or -
unless you want the textboxes to be editable independently - even the
textboxes. You can use the stLinkCriteria to directly control which records
are displayed on the [Issues Count1] form.

Note that a Date *IS NOT A STRING* - a Date/Time value is actually a number, a
count of days and fractions of a day (times) since midnight, December 30,
1899.

Try

Private Sub August_Click()
On Error GoTo Err_Command151_Click
Dim stDocName As String
Dim stLinkCriteria As String

' set up stLinkCriteria to correctly select the desired dates
stLinkCriteria = "[datefield] >= #" & DateSerial(Year(Date()), 8, 1) _
& "# AND [datefield] < #" & DateSerial(Year(Date()), 9, 1) & "#"
stDocName = "Issues Count1"
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_Command151_Click:
Exit Sub

This will give records in the current year only - for example, if you click
the December button now, you'll get only records from the coming December. If
there aren't any in the table you will of course get nothing. This can be
tweaked to give last year's data if the selected month has not yet arrived.
 
John W. Vinson said:
Hi , is it possible to write code behind a button for something to happen in
twelve command buttons, one for each month and would like the command button
when pressed to place the current month at the top of the form (Issues
count1) in a text field. The code behind the button is as follows: Thanks
Tony. hope you understand !!

I'd use a quite different approach: you don't need OpenArgs at all, or -
unless you want the textboxes to be editable independently - even the
textboxes. You can use the stLinkCriteria to directly control which records
are displayed on the [Issues Count1] form.

Note that a Date *IS NOT A STRING* - a Date/Time value is actually a number, a
count of days and fractions of a day (times) since midnight, December 30,
1899.

Try

Private Sub August_Click()
On Error GoTo Err_Command151_Click
Dim stDocName As String
Dim stLinkCriteria As String

' set up stLinkCriteria to correctly select the desired dates
stLinkCriteria = "[datefield] >= #" & DateSerial(Year(Date()), 8, 1) _
& "# AND [datefield] < #" & DateSerial(Year(Date()), 9, 1) & "#"
stDocName = "Issues Count1"
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_Command151_Click:
Exit Sub

This will give records in the current year only - for example, if you click
the December button now, you'll get only records from the coming December. If
there aren't any in the table you will of course get nothing. This can be
tweaked to give last year's data if the selected month has not yet arrived.
Thanks for your help, but i am not sure this is what i need, i have a bog
standard form with no code behind it etc, it just shows the graph which is
linked to a query, the date selection is working fine and the graph shows ok,
at the top of my blank form i have a text box that i just want to show the
relevant month (ie January, February etc) when the corresponding button is
pressed from the launch screen.
Hope this makes sense. Tony
 
Thanks for your help, but i am not sure this is what i need, i have a bog
standard form with no code behind it etc, it just shows the graph which is
linked to a query, the date selection is working fine and the graph shows ok,
at the top of my blank form i have a text box that i just want to show the
relevant month (ie January, February etc) when the corresponding button is
pressed from the launch screen.

Since I have no idea about the structure of your form or where the date might
be stored, it's hard to give specific advice; but you should be able to put a
textbox in the header with its Control Source being a datefield in your table.
Set the textbox's Format property to "mmmm" to just show the month name.
 
Back
Top