VBA, Message Boxes and Locks Query

vernthemerciless

New member
Local time
Today, 14:51
Joined
Aug 21, 2008
Messages
3
Can anyone please help me?! I’ve got two problems with a database which I have been creating for the office I work in. I’ve not used visual basic before and therefore this is something of a learning experience.

1. I have a database where many records that do not have a “Status”of “Live” do not need to be edited. To prevent people accidentally editing these records I’ve been trying to code into the form a process whereby if the “Status” of a record is not “Live” then all the other controls are locked. Having looked at the MS website a various forums I’ve got this code written in (at present I’m just try to lock three of the controls until I can get it to work and then expand it to all of them):

Private Sub Form_Current()
If Me.STATUS = "Live" Then
Me.CLAIM.Locked = False
Me.VESSEL.Locked = False
Me.INSURED.Locked = False
Else
Me.CLAIM.Locked = True
Me.VESSEL.Locked = True
Me.INSURED.Locked = True
End If
End Sub

However this doesn’t seem to do anything at all, all the records are still fully editable. Can someone please give me some pointers to get this to work.

2. I also want to create a pop-up box so that when someone logs an “Event” in the history section of the form that it will remind them to schedule a follow-up action. However I also cannot get this to do anything although this would seem to be the correct string from what I’ve read.

Private Sub Date1_Change()
MsgBox ("Continue?")
End Sub

Can anyone help with this?

Thanks

V
 
Try...

Code:
If Trim(Me.STATUS) = "Live" Then
  etc...

Regards,
Tim
 
Simple Software Solutions

The second element of your post

Private Sub Date1_Change()
MsgBox ("Continue?")
End Sub

Suggests you want the user to respond with a Yes or No as to whether to continue or not. If so, use the following

Code:
If MsgBox("Continue ?",vbQuestion+vbYesNo,"Please click Yes or No") = vbYes Then

    'Yes code

Else

   'No code

End If

CodeMaster::cool:
 

Users who are viewing this thread

Back
Top Bottom