Hello,
I'm having some problems using QueryDefs and hoped someone could tell me whats wrong with my code.
I'm starting off simple!
Thanks for any help!
I'm having some problems using QueryDefs and hoped someone could tell me whats wrong with my code.
I'm starting off simple!
Code:
[SIZE=3][COLOR=#000080][FONT=Arial]Private Sub Command145_Click()[/FONT][/COLOR][/SIZE]
[SIZE=3][COLOR=#000080][FONT=Arial]Dim db As DAO.Database[/FONT][/COLOR][/SIZE]
[SIZE=3][COLOR=#000080][FONT=Arial]Dim qdf As DAO.QueryDef[/FONT][/COLOR][/SIZE]
[SIZE=3][COLOR=#000080][FONT=Arial]Dim strSQL As String[/FONT][/COLOR][/SIZE]
[SIZE=3][COLOR=#000080][FONT=Arial]Set db = CurrentDb[/FONT][/COLOR][/SIZE]
[SIZE=3][COLOR=#000080][FONT=Arial]Set qdf = db.QueryDefs("qryMyQuery")[/FONT][/COLOR][/SIZE]
[SIZE=3][COLOR=#000080][FONT=Arial]strSQL = ""[/FONT][/COLOR][/SIZE]
[SIZE=3][COLOR=#000080][FONT=Arial]strSQL = "SELECT C20_tblTargetDetails.[Item ID], C20_tblTargetDetails.FY"[/FONT][/COLOR][/SIZE]
[SIZE=3][COLOR=#000080][FONT=Arial]strSQL = strSQL & " FROM C20_tblTargetDetails"[/FONT][/COLOR][/SIZE]
[SIZE=3][COLOR=#000080][FONT=Arial]strSQL = strSQL & " GROUP BY C20_tblTargetDetails.[Item ID], C20_tblTargetDetails.FY;"[/FONT][/COLOR][/SIZE]
[SIZE=3][COLOR=#000080][FONT=Arial]qdf.sql = strSQL[/FONT][/COLOR][/SIZE]
[SIZE=3][COLOR=#000080][FONT=Arial]DoCmd.OpenQuery "qryMyQuery"[/FONT][/COLOR][/SIZE]
[SIZE=3][COLOR=#000080][FONT=Arial]Set qdf = Nothing[/FONT][/COLOR][/SIZE]
[SIZE=3][COLOR=#000080][FONT=Arial]Set db = Nothing[/FONT][/COLOR][/SIZE]
[SIZE=3][COLOR=#000080][FONT=Arial]End Sub[/FONT][/COLOR][/SIZE]
Thanks for any help!