Form Lock Before Status (1 Viewer)

aftab1965

Registered User.
Local time
Today, 11:50
Joined
Jan 12, 2016
Messages
44
I need a help.

(db Attached)

Thanks for some friends especially “thedbguy” who shared codes to lock a form by a combobox. I disabled/ Locked a form by a combobox, it works but I want to check some fields, which should be populated before form lock as following;

After selecting CLOSED from STATUS COMBO BOX of PREVENTIVE MAINT CLOSED FORM , should be

  • DATE COMPLETED should not be empty (but future date not allowed)
  • REMARKS Combobox should be populated as “ COMPLETED
  • Supervisor Combobox should not be empty
 

Attachments

Micron

AWF VIP
Local time
Today, 03:50
Joined
Oct 20, 2018
Messages
3,408
Did you research anything you're asking for so that you could learn more than you will by having it just done for you? I'm entirely self taught wrt code and can tell you that you'll likely learn more by researching and trying, even if you have to copy and modify code. When code you copy doesn't work as you want and you have to modify it, you're actually farther ahead than if it did.

Having said that, I expect someone will take what you've posted and just give you your fish (metaphorically speaking) but when it comes to doing someone else's work right off the hop, that's not in your best interests.
 

aftab1965

Registered User.
Local time
Today, 11:50
Joined
Jan 12, 2016
Messages
44
Thanks for your reply.
I'm new buddy to access and getting much from here. I acknowledge my weaknesses and trying to overcome. But it is urgently required if someone can help me.
 

bob fitz

AWF VIP
Local time
Today, 08:50
Joined
May 23, 2011
Messages
3,972
I need a help.

(db Attached)

Thanks for some friends especially “thedbguy” who shared codes to lock a form by a combobox. I disabled/ Locked a form by a combobox, it works but I want to check some fields, which should be populated before form lock as following;

After selecting CLOSED from STATUS COMBO BOX of PREVENTIVE MAINT CLOSED FORM , should be

  • DATE COMPLETED should not be empty (but future date not allowed)
  • REMARKS Combobox should be populated as “ COMPLETED
  • Supervisor Combobox should not be empty
IMHO data validation is best done in the forms Before Update event. The record update can be cancelled in this event if the validation fails and a message can be given to the user. E.g. To validate the data in the Supervisor Combobox you might use something like:
Not IsNull(Me.NameOfComboBox)

Give it a try and post back with your code if you have problems :)
 

Gasman

Enthusiastic Amateur
Local time
Today, 08:50
Joined
Sep 21, 2011
Messages
6,353
Thanks for your reply.
I'm new buddy to access and getting much from here. I acknowledge my weaknesses and trying to overcome. But it is urgently required if someone can help me.
You were stating the very same thing back in 2016?
No progress since then?
 

aftab1965

Registered User.
Local time
Today, 11:50
Joined
Jan 12, 2016
Messages
44
You were stating the very same thing back in 2016?
No progress since then?
Sorry Brother! I'm not IT guy besides a Mechanical engineer and not used to be too much connected. I was trying to make a simple db in 2016 and till the time now I again tried Access after this much long period. I have never used Access since 2016.
Moreover I know great heart people are here to support and help each other and not to evaluate someone. Thanks for your guidance.
 

bob fitz

AWF VIP
Local time
Today, 08:50
Joined
May 23, 2011
Messages
3,972
Try:
Code:
    If Nz(Me.Date_Comp, 0) = 0 Or Nz(Me.Remarks, 0) <> "Completed" Or Me.SupervisorID = 0 Then
        MsgBox "Complete all mandatory data", , "Record Can Not Be Saved"
       
        Cancel = True
       
    End If
In the Form's Before Update event
 
Last edited:

aftab1965

Registered User.
Local time
Today, 11:50
Joined
Jan 12, 2016
Messages
44
Try:
Code:
    If Nz(Me.Date_Comp, 0) = 0 Or Nz(Me.Remarks, 0) <> "Completed" Or Me.SupervisorID = 0 Then
        MsgBox "Complete all mandatory data", , "Record Can Not Be Saved"
      
        Cancel = True
      
    End If
In the Form's Before Update event
Thanks #Bob
I always find you helpful.
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Top Bottom