Question: I am inserting data from table `tbl_login` to table `LoginHistory` with date stamp. But I am confused to add Date Stamp with query string.

My Code is:

```
strSQL2 = "SELECT UserID, FirstName, LastName, UserName FROM tbl_login WHERE Username = """ & Me.txt_username.Value & """ AND Password = """ & Me.txt_password.Value & """"

strSQL3 = "INSERT INTO LoginHistory (UserID, FirstName, LastName, UserName, LoginDate)" & strSQL2 & Now()

CurrentDb.Execute strSQL3

```

Answer: 
For find window in OS Windows you can use `FindWindowEx` from the Win32 Api, for example:

1. Because this is original unsafe code you should import functions from user32.dll:

```
[DllImport("user32.dll", SetLastError = true)] static extern IntPtr 
FindWindowEx(IntPtr hwndParent, IntPtr hwndChildAfter, 
string lpszClass, string lpszWindow);

[DllImport("user32.dll", SetLastError = true)]
public static extern IntPtr FindWindowEx(IntPtr parentHandle, IntPtr 
childAfter, 
string className,  string windowTitle);

```
2. After import you can use function like that:

```
 var CaptionTextForLooking = "hello"; // or "Hi"

 var foundWindowPtr = 
 FindWindowEx(IntPtr.Zero,IntPtr.Zero,CaptionTextForLooking 
 ,IntPtr.Zero);

```

More you can find [here](https://www.pinvoke.net/default.aspx/user32.FindWindow)
You can use the [Application.OpenForms](https://learn.microsoft.com/en-us/dotnet/api/system.windows.forms.application.openforms?view=netframework-4.7.2) property.