Hi
I have the following code on a form which runs on the on close event and compacts the database when it reaches a certain size. (which is in a module). But I would like to add the second piece of code to the button as well to disable the shift key. How do I run these to bits of code together? Sorry I am not very experienced with VBA.
Thanks Richard
Code 1
Private Sub closeFrmswitchlogin_Click()
On Error GoTo Err_closeFrmswitchlogin_Click
MsgBox "Access will compact the database if a certain size is reached, so please wait untill the process finishes.", vbInformation, "Please Read!"
CompactCurrentFile
DoCmd.Quit
Exit_closeFrmswitchlogin_Click:
Exit Sub
Err_closeFrmswitchlogin_Click:
MsgBox err.Description
Resume Exit_closeFrmswitchlogin_Click
End Sub
Code 2
Private Sub Command23_Click()
'This code disables shift key'
Dim db As Database
Dim prop As DAO.Property
Set db = CurrentDb
Set prp = db.CreateProperty("allowbypasskey", dbBoolean, False)
db.Properties.Append prp
End Sub
I have the following code on a form which runs on the on close event and compacts the database when it reaches a certain size. (which is in a module). But I would like to add the second piece of code to the button as well to disable the shift key. How do I run these to bits of code together? Sorry I am not very experienced with VBA.
Thanks Richard
Code 1
Private Sub closeFrmswitchlogin_Click()
On Error GoTo Err_closeFrmswitchlogin_Click
MsgBox "Access will compact the database if a certain size is reached, so please wait untill the process finishes.", vbInformation, "Please Read!"
CompactCurrentFile
DoCmd.Quit
Exit_closeFrmswitchlogin_Click:
Exit Sub
Err_closeFrmswitchlogin_Click:
MsgBox err.Description
Resume Exit_closeFrmswitchlogin_Click
End Sub
Code 2
Private Sub Command23_Click()
'This code disables shift key'
Dim db As Database
Dim prop As DAO.Property
Set db = CurrentDb
Set prp = db.CreateProperty("allowbypasskey", dbBoolean, False)
db.Properties.Append prp
End Sub