Hi all,
This is my 1st select query in VBA.. The data returned will ALWAYS be only ONE record and the data will be used to populate a new excel spreadsheet generated from an excel template (.xlt).
My problem is that I get the error
Cannot Execute a Select Query.
Can someone point me in the right direction to eliminate this error? Thanks
Dim cmbvalue As String
Dim strSQL As String
Dim db As Database
Set db = CurrentDb
cmbvalue = Me.frm_report_summ_combo.Value
strSQL = "SELECT"
strSQL = strSQL & " [tbl_audit].[audit_no]"
strSQL = strSQL & ", [tbl_customer].[cust_name]"
strSQL = strSQL & ", [tbl_customer].[ccan]"
strSQL = strSQL & ", [tbl_customer].[cust_addr1]"
strSQL = strSQL & ", [tbl_customer].[cust_city]"
strSQL = strSQL & ", [tbl_customer].[cust_state]"
strSQL = strSQL & ", [tbl_customer].[cust_zip]"
strSQL = strSQL & ", [tbl_customer].[cust_contact_phone]"
strSQL = strSQL & ", [tbl_customer].[cust_contact_name]"
strSQL = strSQL & ", [tbl_extra_customer].[cust_fax]"
strSQL = strSQL & ", [tbl_extra_customer].[cust_compl_coord]"
strSQL = strSQL & ", [tbl_extra_customer].[cust_type]"
strSQL = strSQL & ", [tbl_audit].[audit_physical_date]"
strSQL = strSQL & ", [tbl_audit].[audit_posted_date]"
strSQL = strSQL & ", [tbl_audit].[audit_days_to_close]"
strSQL = strSQL & ", [tbl_audit].[audit_extension]"
strSQL = strSQL & vbLf
strSQL = strSQL & "FROM ([tbl_customer]"
strSQL = strSQL & "INNER JOIN [tbl_extra_customer]"
strSQL = strSQL & "ON [tbl_customer].[ccan] = [tbl_extra_customer].[ccan])"
strSQL = strSQL & "INNER JOIN [tbl_audit]"
strSQL = strSQL & "ON ([tbl_customer].[ccan] = [tbl_audit].[ccan])"
strSQL = strSQL & "AND ([tbl_extra_customer].[ccan] = [tbl_audit].[ccan])"
strSQL = strSQL & vbLf
strSQL = strSQL & "WHERE ((([tbl_audit].[audit_no]) = cmbvalue))"
CurrentDb.Execute strSQL
If I did not say it before, I really appreciate the time and expertise of the users on this forum.
This is my 1st select query in VBA.. The data returned will ALWAYS be only ONE record and the data will be used to populate a new excel spreadsheet generated from an excel template (.xlt).
My problem is that I get the error
Cannot Execute a Select Query.
Can someone point me in the right direction to eliminate this error? Thanks
Dim cmbvalue As String
Dim strSQL As String
Dim db As Database
Set db = CurrentDb
cmbvalue = Me.frm_report_summ_combo.Value
strSQL = "SELECT"
strSQL = strSQL & " [tbl_audit].[audit_no]"
strSQL = strSQL & ", [tbl_customer].[cust_name]"
strSQL = strSQL & ", [tbl_customer].[ccan]"
strSQL = strSQL & ", [tbl_customer].[cust_addr1]"
strSQL = strSQL & ", [tbl_customer].[cust_city]"
strSQL = strSQL & ", [tbl_customer].[cust_state]"
strSQL = strSQL & ", [tbl_customer].[cust_zip]"
strSQL = strSQL & ", [tbl_customer].[cust_contact_phone]"
strSQL = strSQL & ", [tbl_customer].[cust_contact_name]"
strSQL = strSQL & ", [tbl_extra_customer].[cust_fax]"
strSQL = strSQL & ", [tbl_extra_customer].[cust_compl_coord]"
strSQL = strSQL & ", [tbl_extra_customer].[cust_type]"
strSQL = strSQL & ", [tbl_audit].[audit_physical_date]"
strSQL = strSQL & ", [tbl_audit].[audit_posted_date]"
strSQL = strSQL & ", [tbl_audit].[audit_days_to_close]"
strSQL = strSQL & ", [tbl_audit].[audit_extension]"
strSQL = strSQL & vbLf
strSQL = strSQL & "FROM ([tbl_customer]"
strSQL = strSQL & "INNER JOIN [tbl_extra_customer]"
strSQL = strSQL & "ON [tbl_customer].[ccan] = [tbl_extra_customer].[ccan])"
strSQL = strSQL & "INNER JOIN [tbl_audit]"
strSQL = strSQL & "ON ([tbl_customer].[ccan] = [tbl_audit].[ccan])"
strSQL = strSQL & "AND ([tbl_extra_customer].[ccan] = [tbl_audit].[ccan])"
strSQL = strSQL & vbLf
strSQL = strSQL & "WHERE ((([tbl_audit].[audit_no]) = cmbvalue))"
CurrentDb.Execute strSQL
If I did not say it before, I really appreciate the time and expertise of the users on this forum.