Link to home
Start Free TrialLog in
Avatar of lachstock
lachstockFlag for Australia

asked on

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?
Avatar of DatabaseMX (Joe Anderson - Former Microsoft Access MVP)
DatabaseMX (Joe Anderson - Former Microsoft Access MVP)
Flag of United States of America image

On Update event ?

Can you post the entire code ...

mx
Avatar of lachstock

ASKER

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.
ASKER CERTIFIED SOLUTION
Avatar of DatabaseMX (Joe Anderson - Former Microsoft Access MVP)
DatabaseMX (Joe Anderson - Former Microsoft Access MVP)
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
sorry no good, input form with docketnum = 10 and no msgbox pops up......
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
sorry still no good.  The Mod 10 = 0 should work right?
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
number, database uploaded.

XLD-Quality-Receipts.accdb
ok thats odd.....did you make any changes?
What could be the problem at my end?
No changes at all ... Well, I added one new record with DN of 22 ...

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?
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
yes tried the one you uploaded, no good.
no other machine accessible at the moment.
I have also tested DB and it is working (Access 2010)
Avatar of Rahul Sehrawat
Rahul Sehrawat

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
<<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.
"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
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?
" 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
"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
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.
Yeah, maybe I should clarify ... I'm using the Nav buttons to move through the records - see image.

mx
Capture1.gif
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
https://www.experts-exchange.com/questions/27512064/Access-2007-default-number-ID-on-form-open.html 

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