I have a small issue.....
DDA3 = "SELECT DDAs.[QR Code], DDAs.[Drug Name and Strength],DDAs.[Dispensing Date], DDAs.[Amount Prescribed], DDAs.[Prescription Date], DDAs.[Record Number], DDAs.[NOT DISPENSED] " _
& "FROM DDAs " _
& "WHERE ([DDAs].[QR Code] = [QR Code] AND [DDAs].[Dispensing Date] = [Date 2] AND [DDAs].[NOT DISPENSED] = No) " _
The above gives me the error
When i replace in the WHERE section [Date 2] with Date() (to use today's date instead of the date in the control) it works correctly....
I need to use [Date 2] I tried renaming the control constantly same error, tried removing [QR Code] to statement has only one control still did not work...
(Full code is below:
'On Error Resume Next
[Date 2] = Date
Dim rs As DAO.Recordset
Dim strOutput As String
Dim i As Integer
'Dim Date2 As Date
DDA3 = "SELECT DDAs.[QR Code], DDAs.[Drug Name and Strength],DDAs.[Dispensing Date], DDAs.[Amount Prescribed], DDAs.[Prescription Date], DDAs.[Record Number], DDAs.[NOT DISPENSED] " _
& "FROM DDAs " _
& "WHERE ([DDAs].[QR Code] = [QR Code] AND [DDAs].[Dispensing Date] = [Date 2] AND [DDAs].[NOT DISPENSED] = No) " _
'OR ([DDAs].[QR Code]=[QR Code] AND [DDAs].[Dispensing Date]= [DateMod] AND [DDAs].[NOT DISPENSED]= No) " _
Set rs = CurrentDb.OpenRecordset(DDA3)
With rs
'test for empty recordset
If Not .EOF And Not .BOF Then
.MoveLast
.MoveFirst
Dim cdg As String
cdg = UCase([Forms]![POYC].[txtEnterState6])
For i = 0 To (.RecordCount - 1)
'test for last record
If i = (.RecordCount - 1) Then
'last record
strOutput = strOutput + ![Amount Prescribed] + " " + ![Drug Name and Strength]
Else
'all other records
strOutput = strOutput + ![Amount Prescribed] + " " + ![Drug Name and Strength] + vbCrLf
End If
.MoveNext
Next
End If
.Close
End With
'execute messagebox
MsgBox "The following DDA prescriptions for " & [cdg] & " have been dispensed:" & vbCrLf & vbCrLf & UCase([strOutput]), vbInformation + vbOKOnly, "DDA records!"
Set rs = Nothing
I have some code which I intentionally told access to ignore for now until i find the solution.... i plan to add the or part to the where statement so It runs the query either by Date() or by [Date 2]
Any Ideas?