in a tConfig table, set the HomePC i.p. addresss.
then when the user opens it, check if they match:
Code:
vHome = DLookup("[HomePC]", "tConfig")
vThisPC = getMyIP()
if vHOme <> vThisPC then
msgbox "Don't copy this program"
docmd.quit
endif
save code below to modIP
Code:
Option Compare Database
Option Explicit
'this builds an update query by scanning the form, and collecting ONLY the fields that are NOT NULL.
Public Sub SavePoLocalData2Sql()
Dim sSql1, sSql2, sSql3
Dim ctl As control
Dim colFlds As New Collection
Dim i As Integer
Dim vFld
'On Error Resume Next
sSql1 = "UPDATE dbo_tblPlasticsExtChecklist INNER JOIN tblTakeUpLocal ON dbo_tblPlasticsExtChecklist.ID = tblTakeUpLocal.ID set "
Debug.Print "UPDATE dbo_tblPlasticsExtChecklist INNER JOIN tblTakeUpLocal ON dbo_tblPlasticsExtChecklist.ID = tblTakeUpLocal.ID set "
'loop thru each fld 1 at a time adding to the sql if its NOT NULL
'gather UNIQ fields
On Error Resume Next
For Each ctl In Controls
If IsValidCtlBox2Save(ctl) Then
Select Case ctl.ControlSource
Case "ID", "FO#", "QC#", "ProdCode"
Case Else
If IsNull(ctl) And ctl.ControlSource <> "" And Left(ctl.ControlSource, 1) <> "=" Then
vFld = ctl.ControlSource
colFlds.Add vFld, vFld
End If
End Select
End If
Next
'cycle thru uniq fields to build the upd sql
For i = 1 To colFlds.Count
sSql2 = sSql2 & " dbo_tblPlasticsExtChecklist.[" & colFlds(i) & "] = [tblTakeUpLocal].[" & colFlds(i) & "],"
Next
Debug.Print sSql2
'remove last comma
sSql2 = Left(sSql2, Len(sSql2) - 1)
sSql3 = " WHERE ((dbo_tblPlasticsExtChecklist.ID)=[Forms]![frmPlasExtChecklist_Edit]![ID]);"
'Debug.Print " WHERE ((dbo_tblPlasticsExtChecklist.ID)=[Forms]![frmPlasExtChecklist_Edit]![ID]);"
Debug.Print sSql1
Debug.Print sSql2
Debug.Print sSql3
TraceMasterSql sSql2 'trace the sql
Run1Qry sSql1 & sSql2 & sSql3, True
Set colFlds = Nothing
End Sub
Public Function IsValidCtlBox2Save(ctl As control) As Boolean
IsValidCtlBox2Save = TypeName(ctl) = "TextBox" Or TypeName(ctl) = "ComboBox" Or TypeName(ctl) = "CheckBox"
End Function