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 MikeeOK on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Is it possible to run macro based on combobox selection on form?

Status
Not open for further replies.

awinnn

MIS
Jul 21, 2003
166
MY
Hi,
I have form with combobox, cboYear and button. I have macro, macro1 that will output to the excel file.
This is what i've done,

Dim tWhereClaus As String
tWhereClaus = "[yyyy] = '" & Me.cboYear & "'"
DoCmd.RunMacro "macro1", tWhereClaus

Is it possible to run macro1 within that selected year only?
thanx..:)
 
are you just running the one macro, or are you meaning to amend the macro for each run?

if the former, simply have a sub on a button click that does as follows:

sub #button name#_click

if #comboboxname#.value = "2003" then '(example year only)
docmd.runmacro "macro1"
endif

end sub


if the latter, then amend your macro to look at the combobox's value and then run when required.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top