By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,417 Members | 904 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,417 IT Pros & Developers. It's quick & easy.

Querying table with looping date finction

P: 2
Hello,

I am trying to do basically this, the actual SQL is much uglier but if someone can help with this I would be able to adapt it to that. Here is basically my VB:

Expand|Select|Wrap|Line Numbers
  1. Option Compare Database
  2.  
  3. Option Explicit
  4.  
  5. Function CreateDate()
  6. Dim strSQL As String
  7. Dim StartDate, EndDate, MyDate As Date
  8. Dim rs As DAO.Recordset
  9. StartDate = #1/1/2013#
  10. EndDate = #1/31/2013#
  11. CreateDate = StartDate
  12. While CreateDate <> EndDate
  13. CreateDate = CreateDate + 1
  14. strSQL = "Select * from Sheet1" & _
  15. "Where [Field2] = " & CreateDate
  16. Set rs = CurrentDb.OpenRecordset(strSQL)
  17. Debug.Print strSQL
  18. Wend
  19. End Function
Nick
Apr 5 '13 #1
Share this Question
Share on Google+
3 Replies


Rabbit
Expert Mod 10K+
P: 12,382
Please use code tags when posting code.

I don't know what your question is. As far as the title of thread, "Querying table with looping date finction", you're already doing that. So I'm not sure what it is that you're having trouble with.
Apr 5 '13 #2

P: 2
Thanks for the edit. I will add the code tags in the future. The problem I am having is I get an error when executing. And the debug points to rs. When I remove the rs and really just try and output a value I don't have anything returned. I will post more information tonight about the problem but that is the jist of the issue
Apr 5 '13 #3

Rabbit
Expert Mod 10K+
P: 12,382
When you do, please post the full error message.
Apr 5 '13 #4

Post your reply

Sign in to post your reply or Sign up for a free account.