I have created a form that allows the user to select some options that would turn into a line chart. I could set up line charts all day but as soon as I make some criteria that is dependant on a users choice it flips out. the data comes back correct but the chart will not output anything. I have searched the web for an answer and gave up. I am now currently trying to create a dynamic query that will then turn into a report. it works except for one thing, It will not work unless i encase one line in apostrophes ('). however, when i do, the chart won't accept the data. damned if i do and damned if i don't. the code is below:
Code:
Private Sub Command47_Click()
Dim db As DAO.Database
Dim qdf As DAO.QueryDef
Dim strSQL As String
Set db = CurrentDb
Set qdf = db.QueryDefs("Dynamic_Query")
strSQL = "SELECT T_BD.Gender, T_BD.DateCollected, T_BD.WhiteBloodCellCount " & _
"FROM T_BD " & _
"WHERE T_BD.Gender='" & Me.Gender_.Value & "' " & _
"AND T_BD.DateCollected= 'Between #" & Me.Text9.Value & "# And #" & Me.Text11.Value & "#';" 'This line is the line that won't work without an apostrophe (')
qdf.SQL = strSQL
DoCmd.OpenReport "Dynamic_Report", acViewPreview
Set qdf = Nothing
Set db = Nothing
'Debug.Print strSQL
'MsgBox strSQL
End Sub
Above you can see that I am trying to gather a gender whether it is Male, Female, or Both and a range of dates. that is all. It should not be this hard to do.
This is what the report should look like:
This is what it ends up looking like:
And it's all because of the little apostrophe right here:
I have tried to delete the apostrophes but than the SQL statement throws an error.
Does anyone know of a good solution for the above issue or at least for me to generate a line chart with some simple user input?