Jump to content

InputBox - Using the data in a Date


STeesDCC

Recommended Posts

Sorry if the title is a bit vague, but I'll explain:I have a listbox with all the Months listed, and want to find the records for the relevant month selected. The code was as such;...If Combo39.Text = "January" Then strSQL = "SELECT * FROM [Dafne Course] WHERE [Course Date] BETWEEN #01/01/2008# AND #01/31/2008# AND DNumber is not null"...This works fine (obviously) but when it comes to next year, it will only be able to access one year's results at a time depending on what I change it to (2008/2009)I therefore made an inputbox which the user would enter the year they wish to get the information from after selecting the month they wantHowever, I cannot concatenate the year into the Select statement and have tried various ways such as;...strYear = InputBox("Which Year?")... strSQL = "SELECT * FROM [Dafne Course] WHERE [Course Date] BETWEEN #01/01/'" & strYear & "'# AND #01/31/' strYear '# AND DNumber is not null"...and also...firstDate = "06/01/" & [strYear]lastDate = "07/01" & [strYear]... strSQL = "SELECT * FROM [Dafne Course] WHERE [Course Date] >=#" & [firstDate] & "# AND [Course Date] <=#" & [lastDate] & "# AND DNumber is not null"...But none have worked. The annoying thing is that the latter piece of code works when using a message box (eg msgbox firstdate gives 06/01/2008 when I put 2008 into the input box)Can anybody help?Nathan(Sorry if I have just talked jibberish, but I have explained as best as I can...although I'm almost certain it'll be a simple daft mistake on my part!)

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...