I hope I explain this right:
To keep usage statistics of a variety of databases my company subscribes to, i have a main user form where you enter the month and year then click a button that represents a database. This opens another user form for that database. I enter the info, click submit and the data fills a worksheet for that database, putting the data in the cells of the chosen month and year. Using IF and THEN statements, I can get the first year to work fine, but any subsequent years nothing happens. I'm probably missing something with nesting but can't figure it out. Below is an example of the first two years. The 2011 statements work, but when I choose 2012, the 2011 statement runs again.
I've tried "Else if", "Or" and "And" but get errors that I can't resolve. I'm no programmer so there may be better ways to write the IF statements like variables or something, but I don't know how to do them. The statements work, so that was good enough.Private Sub cmdGales_Click() 'pass the textbox values to the other form Me.Hide If cboYear.Value = "2011" And cboMonth.Value = "January" Or cboMonth.Value = "February" Or cboMonth.Value = "March" Or cboMonth.Value = "April" Or cboMonth.Value = "May" Or cboMonth.Value = "June" Then gale1 Else gale2 If cboYear.Value = "2012" And cboMonth.Value = "January" Or cboMonth.Value = "February" Or cboMonth.Value = "March" Or cboMonth.Value = "April" Or cboMonth.Value = "May" Or cboMonth.Value = "June" Then gale3 Else gale4 End If End If End Sub
Any help would be greatly appreciated.
Last edited by Leith Ross; 04-17-2010 at 06:01 AM. Reason: Added Code Tags
Hello cosber,
Welcome to the Forum!
There are some rules you need to be aware of when you post.
1. Your thread title should clearly describe your problem or question.
2. To make the code easier to read and copy, format it with Code Tags.
Because you are new, I have wrapped the code for you. A better title would be "Problem nesting IF...THEN statements".
As a new member, please take some time to familiarize yourself with the rules.
Forum Rules
Sincerely,
Leith Ross
Remember To Do the Following....
1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.2. Thank those who have helped you by clicking the Starbelow the post.
3. Please mark your post [SOLVED] if it has been answered satisfactorily.
Old Scottish Proverb...
Luathaid gu deanamh maille! (Rushing causes delays!)
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks