Solved Validation Rules on Form Close/Click on Previous record

Tony,
I have a feeling she'll pick up on that little secret if she's following the forum.;)
Has she ever created Youtube content? Good voice, knowledgeable and experienced.

It would be nice if the Northwind 2 had some similar basic, but critical, info.
Stay tuned. It might turn out that way. ;)

Unfortunately, projects like this tend to take a long time to complete.
 
Tony,

See. George spotted a secret within my message.🕵️‍♂️
 
Has she ever created Youtube content? Good voice, knowledgeable and experienced.

Exactly! She's a natural!
 
Tony,

See. George spotted a secret within my message.🕵️‍♂️
"It would be nice if the Northwind 2 had some similar basic, but critical, info"

I assumed you meant documentation and video support. We won't try to teach Access. We'll try to explain how "Northwind" illustrates features. But that's a big task, too.
 
Thanks Pat and Tony for the sharing of this knowledgeable and informative video.

You both have deeply cleared that what the access is doing at the back end on behalf of us if we are doing something wrong.

And cleared so many points which i was wandering around.

Thanks a lot.
 
(it's not really my video, it's mostly Pat!)

The video represents an interesting collaboration between the USA and UK.

Pat hosted the meeting on gotomeeting, on which she has an account.

I recorded it with screencast-o-matic, and shared it on screencast-o-matic hosting, which I haven't used much before. I usually use YouTube.

>>>Edit<<<
Also we are over 3000 miles apart, and working together. IT'S amazing!
 
Last edited:
I give a salute to @CJ_London and @Pat Hartman to drive me into a new direction of database and form making and pushed me to make a single form for all of my inventory project.

I was a lit bit nervous at that time and at the end I have got success to finalise in that way. Still some points are remaining which would be posted later on.

Thanks a lot all of those who have given response time to time.
 
Last edited by a moderator:
Thanks to all for the positive feed back. I like the interview format. It gives Tony an opportunity to ask questions he thinks the viewer might have. The form showing the events was an after thought but once I got it working I realized how very important it is as a learning tool. Tony and I had a few chuckles while we were making the video as we discovered events running that we didn't expect to run. One made the cut in the video.

The next video will show when and when not to use the control's BeforeUpdate event and hopefully also why you would never need to use events other than the two BeforeUpdate events for validation and if you do, hopefully the event log will clarify how bad data will slip through the cracks and get saved. Then I'll move on to other events. I'm open to suggestions so if you have a favorite, I'll consider it. Otherwise the third will be the BeforeInsert event and the Current event will probably be the fourth.

I came to Access as an experienced developer but I was using procedural logic which is quite different from event driven logic. I think form events are one of the most difficult things for newcomers to get their heads around. Even experienced Access developers have trouble figuring out which one to use.

I'm thinking about how best to enable users to import parts of my database so they can use the forms to show events in their own applications. The curmudgeon's way is to add the logging call to each event of your own form but that becomes a PITA. It is important that ALL events get logged so you can always see which ones run when. Since I've done this logging in one place, I will add a way to turn it off so you can actually leave it in your app but not write the log records unless you want to.
 
The same thing I have written that if anyone of the conditions will not met then it will pop up message.
 
Very helpful to see the Order of Events.
Absolutely. I did something similar a few years back but it was very crude - A MsgBox on each event so I could figure out what the blazes was going on. Their demo is MUCH more practical and informative.
 
@paisenhi8 Welcome aboard:) I think we may have a language problem with your post. Try to write it in your own language and then use Google Translate to convert it to English. As long as we know you are using a translator, we can usually figure out what you mean when the translator produces something strange. Our membership is world wide and you might even find someone who understands your native language.

Also, unless your post is regarding the thread you posted in, it is far better to start a new thread for your own question rather than tack it onto an existing thread. Try again and we'll do our best to help you.
 
I have applied validation rule on before update event but I am getting compile error kindly check and suggest please. I have added the code and screenshot.
Code:
Private Sub Form_BeforeUpdate(Cancel As Integer)
    If Forms!frmTransactionsMain!lblReceipt.Visible = True Then
        If CheckForEmpty = False Then
            MsgBox "Please fill in the coloured fields"
        Else
            MsgBox "Do Action"
        End If
    End If

End Sub

Function CheckForEmpty() As Boolean
   
    CheckForEmpty = True
    ClearControlFormatting
   
    Dim Ctrl As Control
   
    For Each Ctrl In Me.Controls
        If Ctrl.Tag = "Fill" Then
            If IsNull(Ctrl) Or Len(Ctrl) = 0 Then
                Ctrl.BackColor = RGB(153, 204, 255)
                CheckForEmpty = False
            End If
        End If
    Next
End Function

Sub ClearControlFormatting()
    Dim Ctrl As Control
   
    For Each Ctrl In Me.Controls
        If Ctrl.Tag = "Fill" Then
            Ctrl.backcolor = vbWhite
        End If
    Next
End Sub

Private Sub Form_Current()
    ClearControlFormatting
End Sub

It is showing compile error on "=" sign on CheckForEmpty in before update event.

Kindly suggest
 

Attachments

  • Capture.GIF
    Capture.GIF
    32.9 KB · Views: 103
Last edited:
I have applied validation rule on before update event but I am getting compile error kindly check and suggest please. I have added the code and screenshot.
Code:
Private Sub Form_BeforeUpdate(Cancel As Integer)
    If Forms!frmTransactionsMain!lblReceipt.Visible = True Then
        If CheckForEmpty = False Then
            MsgBox "Please fill in the coloured fields"
        Else
            MsgBox "Do Action"
        End If
    End If

End Sub

Function CheckForEmpty() As Boolean()
   
    CheckForEmpty = True
    ClearControlFormatting
   
    Dim Ctrl As Control
   
    For Each Ctrl In Me.Controls
        If Ctrl.Tag = "Fill" Then
            If IsNull(Ctrl) Or Len(Ctrl) = 0 Then
                Ctrl.BackColor = RGB(153, 204, 255)
                CheckForEmpty = False
            End If
        End If
    Next
End Function

Sub ClearControlFormatting()
    Dim Ctrl As Control
   
    For Each Ctrl In Me.Controls
        If Ctrl.Tag = "Fill" Then
            Ctrl.baccolor = vbWhite
        End If
    Next
End Sub

Private Sub Form_Current()
    ClearControlFormatting
End Sub

It is showing compile error on "=" sign on CheckForEmpty in before update event.

Kindly suggest
Good morning. @GinaWhipp has the best Form Validation sub I have ever seen. Place her code in your BeforeUpdate event and your life will be much easier!
 
I would start by removing the brackets after Boolean() in your CheckForEmpty() function.
 
I would start by removing the brackets after Boolean() in your CheckForEmpty() function.
Thanks @jdraw, i have removed () now no error but the form is not showing any response on blank fields. Kindly suggest.

@NauticalGent , this is beyond my scope, may be this would work, thanks
 
Last edited:
@NauticalGent , this is beyond my scope, may be this would work, thanks
Really nothing to it. You would place the code in a standard module (outside of any of your forms), then in each of your forms' BeforeUpdate event you would call it with
Code:
If fValidateData Then
     Cancel = True
     Exit Sub
End If
 
I will try
Really nothing to it. You would place the code in a standard module (outside of any of your forms), then in each of your forms' BeforeUpdate event you would call it with
Code:
If fValidateData Then
     Cancel = True
     Exit Sub
End If

I have tried this, this works but as you get notification of blank fields it freezes the form and records, and even after filling again the required fields it does not unfreezes the form fields.
 

Users who are viewing this thread

Back
Top Bottom