Skip to content

Instantly share code, notes, and snippets.

View DoronFCG's full-sized avatar

DoronF DoronFCG

View GitHub Profile
@DoronFCG
DoronFCG / Blog_MS_Access_fieldexists function_3
Created July 24, 2022 20:23
Create fieldexists function if you want to test the file structure in the code above
Public Function fieldexists(tablename As String, fieldname As String) As Boolean
Dim exists As Boolean
exists = False
On Error Resume Next
exists = CurrentDb.TableDefs(tablename).Fields(fieldname).name = fieldname
fieldexists = exists
End Function
@DoronFCG
DoronFCG / Blog_MS_Access_Create_an_Update Event_1
Last active July 24, 2022 20:10
Blog - MS Access Drag and Drop Box functionality and Create an After Update Event
Public strFileName As String '' Set strFileName as a public variable
Private Sub DDBox_AfterUpdate()
'' The code below will set the strFileName variable equal to the file path of the file that is dragged onto it.
Dim fso As New FileSystemObject '' Microsoft Scripting Runtime required
strFileName = fso.GetParentFolderName(Me.DDBox.Hyperlink.address)
Me.DDBox = Null
If strFileName = "" Then Exit Sub
'' Execute the DDBoxRoutine defined below
DDBoxRoutine
DECLARE @StringForColors AS VARCHAR(80),
@Result AS VARCHAR(80);
SET @StringForColors = 'Red,Green,Blue,Black,Yellow,Brown,Purple,Pink,Silver,Gold,Burgundy';
SET @Result = REPLACE(@StringForColors, ',', CHAR(10) + CHAR(13));
SELECT @Result AS 'See Colors with a Line Feed as well';
DECLARE @StringForColors AS VARCHAR(80),
@Result AS VARCHAR(80);
SET @StringForColors = 'Red,Green,Blue,Black,Yellow,Brown,Purple,Pink,Silver,Gold,Burgundy';
SET @Result = REPLACE(@StringForColors, ',', CHAR(10));
SELECT @Result AS 'See Colors with a Line break';
@DoronFCG
DoronFCG / blog_20200112_ExportToExcelAllowed_3.js
Created January 13, 2020 03:54
This the JS function which is called from the Export to spread sheet Button based on different conditions. It is based on the Disable Enable button's property in the UX component for the Alpha AnyWhere software development.
function ExportToExcelAllowed(ActivityDateFrom, ActivityDateTo, ActivityUserSelection)
{
var ButtonColor = '#808080' ;
var RetVal = false ;
if ((ActivityDateFrom != '') || (ActivityDateTo != '') || (ActivityUserSelection != ''))
{
ButtonColor = 'Blue'
var RetVal = true ;
}
@DoronFCG
DoronFCG / blog_20200112_2.js
Created January 13, 2020 03:11
Get the innerHTML code from the Google Chrome Debugger Console and Replce the BLG1 with {dialog.ComponentName} which is Alpha AnyWhere place holder. The blue color with the gray color: #808080 as shown below:
<font color="#808080"><strong>Export </strong></font> <img src="images/disabled/$$application.ms.excel.png.a5image" id="{dialog.ComponentName}.V.R1.BUTTON_EXPORT_TO_EXECL.ICON" class="" style="vertical-align: middle; border: none;">
@DoronFCG
DoronFCG / blog_20200112_1.js
Last active January 13, 2020 03:22
The innerHTML code extracted via the Google Chrom Debugger. This related to Alpha AnyWhere article of how to change the color on the Enable or Disable function.
<font color="blue"><strong>Export</strong></font><img src="images/$$application.ms.excel.png.a5image" id="DLG1.V.R1.BUTTON_EXPORT_TO_EXECL.ICON" class="" style="vertical-align: middle; border: none;">"
@DoronFCG
DoronFCG / blog_20110114_9.sql
Last active April 21, 2019 18:52
Fix CPU spikes as a result of parameter sniffing while the MS SQL stored procedure is executed
CREATE PROCEDURE GetOrders
@OrderID INT
AS
BEGIN
DECLARE @Local_OrderID AS INT
SET @Local_OrderID = @OrderID;
SELECT
OrderID,
CustomerID,
@DoronFCG
DoronFCG / blog_20110114_8.sql
Last active February 10, 2019 18:09
See example code which runs via an SQL Job every 6 min 5 days a week and takes advantage of the Linked Server. The IP address is a fake one.
TRUNCATE TABLE INV
INSERT INTO INV WITH(tablock)
SELECT
[Inv_NewPK],
[PartNumber],
[PurchasePrice],
[SupplierPN],
[SupplierCode],
[SupplierName],
[PartDesc],
@DoronFCG
DoronFCG / blog_20110114_7.sql
Created January 4, 2019 18:51
The below trigger will store any data into St_Trigger table as Insert, Update and Delete
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER trigger [dbo].[my_tr] on [dbo].[Stock]
FOR INSERT, DELETE,UPDATE
AS
IF EXISTS (SELECT * FROM INSERTED) AND EXISTS (SELECT * FROM DELETED)
INSERT INTO St_trigger (DT,Operation) SELECT GETDATE(),'Update'