Results 1 to 5 of 5
  1. #1
    erickemboi is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Sep 2020
    Posts
    73

    Database to be used by only one computer

    Hello everyone. I would like my database to be used by only one computer.
    If copied the msgbox should be "YOU CANNOT USE THIS DATABASE BECAUSE YOU COPIED FROM ANOTHER COMPUTER" Thanks in advance.

  2. #2
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    6,550
    Search here. It has been asked many times, checking hard disk, network card etc etc
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  3. #3
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,550
    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

  4. #4
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    6,550
    Quote Originally Posted by Welshgasman View Post
    Search here. It has been asked many times, checking hard disk, network card etc etc
    Sorry, wrong forum

    See this thread for getting HD serial number. Logic would be the same as for Ranman's ip address

    https://www.access-programmers.co.uk...serial.311528/
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  5. #5
    erickemboi is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Sep 2020
    Posts
    73
    Mr. ranman 256 please kindly assist me with a sample database. Please. Thanks in advance

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Database will not work on another computer
    By yagerlegi in forum Access
    Replies: 5
    Last Post: 04-03-2015, 09:59 PM
  2. Computer Service Database
    By sdel_nevo in forum Sample Databases
    Replies: 6
    Last Post: 11-18-2014, 08:41 AM
  3. Replies: 4
    Last Post: 11-29-2012, 12:45 AM
  4. Replies: 1
    Last Post: 05-25-2012, 10:36 AM
  5. openning database on another computer
    By rjriggins11 in forum Access
    Replies: 5
    Last Post: 02-22-2011, 02:25 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums