Access 2007 MsgBox for 10th Record

I am trying to create a msg box for every 10th record/id of a form/table.

ID name = DocketNum

Have tried to assign macro to the On Update event of the Form with the following code
[DocketNum] MOD 10 = 0
Msg "email data table"
Keeps saying DocketNum can't be found on the open object.  

Any ideas?
lachstockAsked:
Who is Participating?
 
DatabaseMX (Joe Anderson - Microsoft Access MVP)Database ArchitectCommented:
Maybe this

Private Sub Form_AfterUpdate()
   IF Me!DocketNum Mod 10 = 0 then
        MsgBox "DocketNum= " & Me!DocketNum, "Email Data Table"
  End If
End Sub
0
 
DatabaseMX (Joe Anderson - Microsoft Access MVP)Database ArchitectCommented:
On Update event ?

Can you post the entire code ...

mx
0
 
lachstockAuthor Commented:
sorry after update.

I have no idea when it comes to writting code, but here it is anyway.

Private Sub Form_AfterUpdate()
MsgBox "DocketNum=" & Me!DocketNum, Mod, 10, "Email Data Table"
End Sub

Thanks.
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

 
lachstockAuthor Commented:
sorry no good, input form with docketnum = 10 and no msgbox pops up......
0
 
DatabaseMX (Joe Anderson - Microsoft Access MVP)Database ArchitectCommented:
Well, the After Update event does not trigger until you save a record.  Maybe you want the Current event:


Private Sub Form_Current()
   IF Me!DocketNum Mod 10 = 0 then
        MsgBox "DocketNum= " & Me!DocketNum, "Email Data Table"
  End If
End Sub
0
 
lachstockAuthor Commented:
sorry still no good.  The Mod 10 = 0 should work right?
0
 
DatabaseMX (Joe Anderson - Microsoft Access MVP)Database ArchitectCommented:
Yes ... IF ... DocectNum has one or more values that are evenly divisible by 10.
What is the data type of DocectNum ?

Can you upload the db?

mx
0
 
lachstockAuthor Commented:
number, database uploaded.

XLD-Quality-Receipts.accdb
0
 
DatabaseMX (Joe Anderson - Microsoft Access MVP)Database ArchitectCommented:
It's working for me ...

mx
0
 
DatabaseMX (Joe Anderson - Microsoft Access MVP)Database ArchitectCommented:
0
 
lachstockAuthor Commented:
ok thats odd.....did you make any changes?
What could be the problem at my end?
0
 
DatabaseMX (Joe Anderson - Microsoft Access MVP)Database ArchitectCommented:
No changes at all ... Well, I added one new record with DN of 22 ...

0
 
DatabaseMX (Joe Anderson - Microsoft Access MVP)Database ArchitectCommented:
0
 
lachstockAuthor Commented:
this is frustrating....still doesn't work for me.  Have tried trust center and enabling content etc....
So you have the following;
Private Sub Form_Current()
   If Me!DocketNum Mod 10 = 0 Then
        MsgBox "DocketNum= " & Me!DocketNum, "Email Data Table"
  End If
End Sub

I have also tried

Private Sub Form_Current()
   If Me!DocketNum Mod 10 = 0 Then
        MsgBox "Email Data Table"
  End If
End Sub

Have set up another test msg box on close, it works.  So nothing blocking the msgbox.  Just can't seem to match with the on current or after update event?
0
 
DatabaseMX (Joe Anderson - Microsoft Access MVP)Database ArchitectCommented:
Either of those work.  Yes, I suppose your db needs to be in a Trusted Location. There is nothing wrong with your code for the Current Event ...

Did you try the copy I uploaded - even though it's the same ..?

Do you have another machine you can try on ?

mx
0
 
lachstockAuthor Commented:
yes tried the one you uploaded, no good.
no other machine accessible at the moment.
0
 
als315Commented:
I have also tested DB and it is working (Access 2010)
0
 
Rahul SehrawatCommented:
Once I was facing the same problem in one of the project I was working on..
made the same changes in your project as well.. please check if it worked..
XLD-Quality-Receipts.accdb
0
 
mbizupCommented:
<<What could be the problem  >>

Possibly mis-communication?

When exactly do you want to see this message appear?

Your code is in the Current Event right now, which fires when the form opens and as the user navigates from record to record.  The message will pop up if the form opens to a record whose DocketNumber is a multiple of 10, and as the user navigates to such a record (the sample definitely behaves like that)

If you want the message to appear for DocketNumbers as the user enters new records, you could try placing that code in the AfterUpdate event of the Docket Number textbox.
0
 
DatabaseMX (Joe Anderson - Microsoft Access MVP)Database ArchitectCommented:
"When exactly do you want to see this message appear?"
Not sure that matters.  My code works, proof see screen shot.  Does not work on his machine.

mx
0
 
lachstockAuthor Commented:
still not working, changes made by anshuverma didn't solve the issue.  I am using access 2007 though, would that be part of the problem?
0
 
DatabaseMX (Joe Anderson - Microsoft Access MVP)Database ArchitectCommented:
" I am using access 2007 though, would that be part of the problem?"

There MUST .. be some nuance with A2007 that is keeping this from working.  Like there is nothing to that code ... about as simple as it gets.  Weird.

mx
0
 
DatabaseMX (Joe Anderson - Microsoft Access MVP)Database ArchitectCommented:
"lachstock:

Using the db I uploaded, put a Break  Point right on the Form Current event, then use F8 to single step through that code ... and check the values, etc ...

mx
0
 
mbizupCommented:
The current event runs fine in 2007, as long as you have enabled macros /vba, which you have already confirmed you did.

Can you verify how you are using this ...navigating through records, adding new data, editing existing data, etc?

Just want to double check, per my last comment that you are indeed using the correct event.
0
 
DatabaseMX (Joe Anderson - Microsoft Access MVP)Database ArchitectCommented:
Yeah, maybe I should clarify ... I'm using the Nav buttons to move through the records - see image.

mx
Capture1.gif
0
 
lachstockAuthor Commented:
Turned out is was a simple as aligning the If and End if lines to the left (see below), they were indented/tabbed in in the solution.  Must be an access 2007 thing.....Thanks again for your help.  One more to go if keen;
See post
http://www.experts-exchange.com/Microsoft/Development/MS_Access/Q_27512064.html 

Private Sub Form_Current()
If Me!DocketNum Mod 10 = 0 Then
        MsgBox "Email Data Table"
End If
End Sub
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.