This really puzzles me.
I have a date field in a table. The date that is being searched for changes so the SQL language uses a variable for the date. When I put in an actual date in the SQL language, Access finds the record, but when I replace the date with a formatted variable (and the format matches what is in the table) no recordset is found. So here is the code. I hope someone can tell me what I am doing wrong. I have searched and searched and every solution I find online, does not work. Thanks.
Code:
ShowWeekend = Format(ShowWeekend, "M/D/YYYY"
sqlFindCurrentShow = " SELECT * FROM Show_SalesSummaryLog WHERE Show_Date_Start = " & ShowDateString
Set dbFindCurrentShow = CurrentDb
Set rsRindCurrentShow = dbFindCurrentShow.OpenRecordset(sqlFindCurrentShow)
And ShowWeekend= 9/2/2023
The above code does not find the record. But the code BELOW does:
Code:
sqlFindCurrentShow = " SELECT * FROM Show_SalesSummaryLog WHERE Show_Date_Start = 9/2/2023"
Set dbFindCurrentShow = CurrentDb
Set rsRindCurrentShow = dbFindCurrentShow.OpenRecordset(sqlFindCurrentShow)
What am I misunderstanding.
And thanks again for all who have been helping me with this program. I have been programming in BASIC since I was 5 years old when my grandfather started teaching me on his own kit built Apple II computer, and eventually learning Quick Basic then Visual Basic, and now VBA (since I really don't like VB.net) When it comes to VBA I am "self taught" along with those who have been helping me on forums like this so though I understand the Logic, things like this stump me and drive me crazy as logically it should work but it isn't. So thanks for your patience!
Ken L