I've tried a variety of quotes and ampersands to get this to work, but it's not working. I have a table called tblMonths and the MonthName field is text (January, February, etc), the MonthNumberText field is text (01, 02, 03, etc), and the MonthNumberNum field is double (1, 2, 3, etc). I want to auto-populate a combo box with the MonthName of the prior month end based on today's date. For example, today is 8/21/15, and I want to show July in the combo box.
Neither of the following is working for me.
Neither of the following is working for me.
Code:
ComboBoxMonth.DefaultValue = DLookup("MonthName", "tblMonths", "MonthNumberText = '" & Month(DateSerial(Year(Date), Month(Date) - 1, 1)) & "'")
ComboBoxMonth.DefaultValue = DLookup("MonthName", "tblMonths", "MonthNumberNum = Month(DateSerial(Year(Date), Month(Date) - 1, 1))")