如果写软件的人的查询基本上都是在查询界面生成的话,不涉及复杂代码的软件很容易就可以抄一个。但我写的软件几乎不存在查询。要不直接在窗口报表的数据源那里写的sql语言,要不就是直接通过代码赋值的,例如me.RecordSource=“XXXXXXXXXXXXXX“。这样别人就不可能查看你的查询。其实表和查询是可以隐藏的。以下代码即可
Private Sub 是否隐藏数据表_Click()
If Me.是否隐藏数据表 = True Then
For Each tabdef In CurrentDb.TableDefs
Debug.Print tabdef.Name
Debug.Print tabdef.Attributes
If tabdef.Attributes = 0 Then
tabdef.Attributes = 1
End If
Next
Else
For Each tabdef In CurrentDb.TableDefs
Debug.Print tabdef.Name
Debug.Print tabdef.Attributes
If tabdef.Attributes = 1 Then
tabdef.Attributes = 0
End If
Next
End If
End Sub
通过变成mde,再隐藏表,接着屏蔽掉shift键。别人其实已经对你的软件没辙了。以下是屏蔽shift的代码。跟上面的一样。我放在一个复选框里面的进行设置的。
Private Sub 编辑模式_Click()
On Error Resume Next
Dim p
If Me.编辑模式 = False Then
On Error Resume Next
Set p = CurrentDb.CreateProperty _
("AllowBypassKey", DB_BOOLEAN, False)
CurrentDb.Properties.Append p
CurrentDb.Properties("AllowBypassKey") = False
Else
Set p = CurrentDb.CreateProperty _
("AllowBypassKey", DB_BOOLEAN, True)
CurrentDb.Properties.Append p
CurrentDb.Properties("AllowBypassKey") = True
End If
End Sub