Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

When a database split an error occur when a form is opened

Status
Not open for further replies.

maupiti

Programmer
Oct 27, 2003
240
US
Access 2003

I had a database where all tables, forms, reports, and modules are in one. When a form named "maintenance" is opened, the code below runs.

When this same database is split into a front-end and
a back-end, and I opened the same form named "maintenance"
on the front-end, an error occurred. The program flag the error at the code below

Error message:
Run-time error 3270. Property Not Found.

error flag:
If Dbs.Properties(strPropName) = True Then

//////////////////////////////////////////////////

Private Sub Form_Open(Cancel As Integer)
Dim Dbs As Object
Dim strPropName As String

strPropName = "AllowBypassKey"
Set Dbs = CurrentDb

If Dbs.Properties(strPropName) = True Then
Me!Lock_State = "Unlock"
Else
Me!Lock_State = "Lock"
End If

End Sub
 
Use this function
Code:
Function ChangeProperty(strPropName As String, _
 varPropType As Variant, varPropValue As Variant) As Integer

' The current listing in Access help file which will
' let anyone who can open the db delete/reset any
' property created by using this function, since
' the call to CreateProperty doesn't use the DDL
' argument

 Dim dbs As DAO.Database
 Dim prp As DAO.Property
 Const conPropNotFoundError = 3270

 Set dbs = CurrentDb
 On Error GoTo Change_Err
 dbs.Properties(strPropName) = varPropValue
 ChangeProperty = True

Change_Bye:
 Exit Function

Change_Err:
 If Err = conPropNotFoundError Then ' Property not found.
  Set prp = dbs.CreateProperty(strPropName, varPropType, varPropValue)
  dbs.Properties.Append prp
  Resume Next
 Else
  ' Unknown error.
  ChangeProperty = False
  Resume Change_Bye
 End If
End Function
example of use
Code:
Public Sub subSetAdminProperties()
   ChangeProperty "AllowBypassKey", dbBoolean, False
   ChangeProperty "AllowFullMenus", dbBoolean, True
   ChangeProperty "AllowSpecialKeys", dbBoolean, True
   ChangeProperty "AllowBreakIntoCode", dbBoolean, True
End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top