From 4b6d0c744dbb2ecde27d18c418e9c618a161679c Mon Sep 17 00:00:00 2001 From: Paul Trowbridge Date: Wed, 29 Jan 2020 13:31:32 -0500 Subject: [PATCH] accomodate new sql builder parameters, and test for presence of price sheet --- FL.bas | 48 ++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 42 insertions(+), 6 deletions(-) diff --git a/FL.bas b/FL.bas index da56fba..6fe0f5c 100644 --- a/FL.bas +++ b/FL.bas @@ -14,8 +14,6 @@ Public Enum ColorTier O_rganic = 7 W_axtough = 8 End Enum - - Sub Determine_Active_Range() @@ -59,7 +57,7 @@ Sub Cross_Join_Selection() End If i = i + 1 Next ar - + dest = InputBox("Input row & column numbers like ""3,17""") If dest = "" Then @@ -614,13 +612,43 @@ Sub markdown_whole_sheet() End Sub -Sub sql_from_range() +Sub sql_from_range_db2_qh() Dim x As New TheBigOne Dim wapi As New Windows_API Dim r() As String Selection.CurrentRegion.Select - Call wapi.ClipBoard_SetData(x.SQLp_build_sql_values(x.ARRAYp_get_range_string(Selection), True, True, Db2)) + Call wapi.ClipBoard_SetData(x.SQLp_build_sql_values(x.ARRAYp_get_range_string(Selection), True, True, Db2, True)) + +End Sub + +Sub sql_from_range_db2_noqh() + + Dim x As New TheBigOne + Dim wapi As New Windows_API + Dim r() As String + Selection.CurrentRegion.Select + Call wapi.ClipBoard_SetData(x.SQLp_build_sql_values(x.ARRAYp_get_range_string(Selection), True, True, Db2, False)) + +End Sub + +Sub sql_from_range_pg_qh() + + Dim x As New TheBigOne + Dim wapi As New Windows_API + Dim r() As String + Selection.CurrentRegion.Select + Call wapi.ClipBoard_SetData(x.SQLp_build_sql_values(x.ARRAYp_get_range_string(Selection), True, True, PostgreSQL, True)) + +End Sub + +Sub sql_from_range_pg_noqh() + + Dim x As New TheBigOne + Dim wapi As New Windows_API + Dim r() As String + Selection.CurrentRegion.Select + Call wapi.ClipBoard_SetData(x.SQLp_build_sql_values(x.ARRAYp_get_range_string(Selection), True, True, PostgreSQL, False)) End Sub @@ -822,7 +850,7 @@ Sub extract_price_matrix() '-------------------------prepare sql to upload--------------------------------------------------------------- - sql = x.SQLp_build_sql_values(unp, False, True, Db2) + sql = x.SQLp_build_sql_values(unp, False, True, Db2, False) sql = "DECLARE GLOBAL TEMPORARY TABLE session.plbuild AS (" & sql & ") WITH DATA" Call wapi.ClipBoard_SetData(sql) @@ -918,15 +946,23 @@ Sub go_to_price_issue() Dim trow As Long Dim tcol As Long Dim i As Long + Dim has_Pricesheet As Boolean + has_Pricesheet = False For Each ws In Application.Worksheets For Each cp In ws.CustomProperties If cp.Name = "spec_name" And cp.value = "price_list" Then Set price_sheet = ws + has_Pricesheet = True End If Next cp Next ws + If Not has_Pricesheet Then + MsgBox ("no price sheet found") + Exit Sub + End If + Set orig = Application.Selection Selection.CurrentRegion.Select