SQL = "SELECT " _ & "HistoryInvcTable.f_invc_kind , HistoryInvcTable.f_invc_loc_lit, HistoryInvcTable.f_invc_paym_mode, HistoryInvcTable.f_invc_paym_term, HistoryInvcTable.f_invc_internal_kind, HistoryInvcTable.f_invc_internal_num, HistoryInvcTable.f_invc_internal_lit, HistoryInvcTable.f_invc_internal_year, HistoryInvcTable.f_invc_internal_c_user_name, HistoryInvcTable.f_invc_internal_d, HistoryInvcTable.f_invc_internal_d_exec, " _ & "HistoryInvcTable.f_invc_iss_cli_r_clt_int, HistoryInvcTable.f_invc_iss_adr_r_adr_1, HistoryInvcTable.f_invc_iss_adr_r_adr_2, HistoryInvcTable.f_invc_iss_adr_l_twn, HistoryInvcTable.f_invc_iss_adr_c_post_code, HistoryInvcTable.f_invc_iss_acc_c_bank, HistoryInvcTable.f_invc_iss_acc_r_bank_acc, HistoryInvcTable.f_invc_ic_cli_id, HistoryInvcTable.f_invc_ic_cli_r_clt_int, HistoryInvcTable.f_invc_ic_cli_r_clt_reg_1, HistoryInvcTable.f_invc_ic_cli_r_clt_reg_2, HistoryInvcTable.f_invc_ic_adr_r_adr_1, HistoryInvcTable.f_invc_ic_adr_r_adr_2, HistoryInvcTable.f_invc_ic_adr_l_twn, HistoryInvcTable.f_invc_ic_adr_c_post_code, " _ & "HistoryInvcTable.f_invc_ic_cli_l_cty, HistoryInvcTable.f_invc_cm_cli_id, HistoryInvcTable.f_invc_cm_cli_r_clt_int, HistoryInvcTable.f_invc_cm_cli_r_clt_reg_1, HistoryInvcTable.f_invc_cm_cli_r_clt_reg_2, HistoryInvcTable.f_invc_cm_adr_r_adr_1, HistoryInvcTable.f_invc_cm_adr_r_adr_2, HistoryInvcTable.f_invc_cm_adr_l_twn, HistoryInvcTable.f_invc_cm_adr_c_post_code, HistoryInvcTable.f_invc_cm_cli_l_cty, HistoryInvcTable.f_invc_gross_mnt, " _ & "IteInvcTable.f_ite_invc_desc, IteInvcTable.f_ite_invc_q_prd, IteInvcTable.f_ite_invc_c_unit, IteInvcTable.f_ite_invc_a_unit_prc, IteInvcTable.f_ite_invc_gross_mnt, IteInvcTable.f_ite_invc_mwst_satz, IteInvcTable.f_ite_invc_vat_mnt, IteInvcTable.f_ite_invc_net_mnt, " _ & "MwstDefTable.f_mwst_satz_A, MwstDefTable.f_mwst_satz_C, MwstDefTable.f_mwst_satz_E, MwstDefTable.f_mwst_satz_Z " _ & "FROM " _ & pub_cr.glb_DSNName & ".." & "HistoryInvcTable HistoryInvcTable, " _ & pub_cr.glb_DSNName & ".." & "IteInvcTable IteInvcTable, " _ & pub_cr.glb_DSNName & ".." & "MwstDefTable MwstDefTable " SQL = SQL & "WHERE " _ & "HistoryInvcTable.f_invc_kind = '" & invc_kind & "' AND " _ & "HistoryInvcTable.f_invc_num = " & invc_num & " AND " _ & "HistoryInvcTable.f_invc_lit = '" & invc_lit & "' AND " _ & "HistoryInvcTable.f_invc_year = " & invc_year & " AND " _ & "HistoryInvcTable.f_invc_kind = IteInvcTable.f_ite_invc_kind AND " _ & "HistoryInvcTable.f_invc_num = IteInvcTable.f_ite_invc_num AND " _ & "HistoryInvcTable.f_invc_lit = IteInvcTable.f_ite_invc_lit AND " _ & "HistoryInvcTable.f_invc_year = IteInvcTable.f_ite_invc_year AND " _ & "HistoryInvcTable.f_invc_d BETWEEN MwstDefTable.f_mwst_d_cond_start AND MwstDefTable.f_mwst_d_cond_end"