I have some code that builds an SQL string from data on a form. I now want to save this data as a query and open another form based on it.
What is the code to save the string sSQL which is a select statement as a query? I have searched ans searched and can not find it.
Thanks
Rob
Here is my code that builds the query
Dim rcd as String
rcd = Me.Target_Projects_t_num
Dim sSQL As String 'query string
sSQL = "SELECT [Target_Projects Query].[Target_Projects_Project #], [Target_Projects Query].Location, [Target_Projects Query].DPM, [Target_Projects Query].Target_Projects.t_num, [Contacts Extended].[Contact Name], [Contacts Extended].Company, [Contacts Extended].Address, [Contacts Extended].City, [Contacts Extended].[State/Province], [Contacts Extended].[ZIP/Postal Code]"
sSQL = sSQL + " FROM [Target_Projects Query] LEFT JOIN [Contacts Extended] ON [Target_Projects Query].DPM = [Contacts Extended].[Contact Name] WHERE ((([Target_Projects Query].Target_Projects.t_num)='" & rcd & "'));"
What is the code to save the string sSQL which is a select statement as a query? I have searched ans searched and can not find it.
Thanks
Rob
Here is my code that builds the query
Dim rcd as String
rcd = Me.Target_Projects_t_num
Dim sSQL As String 'query string
sSQL = "SELECT [Target_Projects Query].[Target_Projects_Project #], [Target_Projects Query].Location, [Target_Projects Query].DPM, [Target_Projects Query].Target_Projects.t_num, [Contacts Extended].[Contact Name], [Contacts Extended].Company, [Contacts Extended].Address, [Contacts Extended].City, [Contacts Extended].[State/Province], [Contacts Extended].[ZIP/Postal Code]"
sSQL = sSQL + " FROM [Target_Projects Query] LEFT JOIN [Contacts Extended] ON [Target_Projects Query].DPM = [Contacts Extended].[Contact Name] WHERE ((([Target_Projects Query].Target_Projects.t_num)='" & rcd & "'));"