INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

Mgs does not display

Mgs does not display

(OP)
I converted an app from Access 2003 to 2010 in windows 7. All worked fine except that if the PaymentType is not selected, it should display a message that a PaymentType should be selected before proceeding further. It worked fine in old version but not in 2010. Below is the code. Can't figure out why it does not work.

Private Sub Form_BeforeUpdate(Cancel As Integer)
'Check to make sure a payment type is selected, then update
'the Paidthrough field in the Payment Table
Dim bytMonths As Byte
If PaymentType = 0 Then
DisplayMessage "You must select a payment type."
Cancel = True
Exit Sub
End If

bytMonths = YearsPaid * 13

Select Case PaymentType
Case 1, 2, 3, 4, 10, 12, 13, 14, 18, 22, 23

'If this is the first payment, set Paid Through from current date

If IsNull(PaidThrough) Or PaidThrough < Date Then

PaidThrough = DateSerial(Year(Date), Month(Date) + bytMonths, 1)
PaymentType = PaymentType

Else
'Otherwise, add additional months to the PaidThrough value.
PaidThrough = DateSerial(Year(PaidThrough), Month(PaidThrough) + _
bytMonths, 1)

PaymentType = PaymentType
End If

Case 5, 6, 7, 8, 9, 11, 15, 16, 17, 19, 20, 21, 24, 25, 26
Exit Sub
Case Else
End Select
Exit Sub

End Sub

RE: Mgs does not display

Please post your code using TGML for easier readability.

CODE --> vba

Private Sub Form_BeforeUpdate(Cancel As Integer)
'Check to make sure a payment type is selected, then update
'the Paidthrough field in the Payment Table
    Dim bytMonths As Byte
    If PaymentType = 0 Then
        DisplayMessage "You must select a payment type."
        Cancel = True
        Exit Sub
    End If

    bytMonths = YearsPaid * 13
    Select Case PaymentType
        Case 1, 2, 3, 4, 10, 12, 13, 14, 18, 22, 23
            'If this is the first payment, set Paid Through from current date

            If IsNull(PaidThrough) Or PaidThrough < Date Then
                PaidThrough = DateSerial(Year(Date), Month(Date) + bytMonths, 1)
                PaymentType = PaymentType
              Else
                'Otherwise, add additional months to the PaidThrough value.
                PaidThrough = DateSerial(Year(PaidThrough), Month(PaidThrough) + _
                    bytMonths, 1)
                PaymentType = PaymentType
            End If
        Case 5, 6, 7, 8, 9, 11, 15, 16, 17, 19, 20, 21, 24, 25, 26 'Not Necessary
            Exit Sub 'Not Necessary
        Case Else
    End Select
    Exit Sub         'Not Necessary
End Sub 
  • Apparently there is a custom function or sub "DisplayMessage". Can you share this function using TGML?
  • Does your code compile?
  • Have you attempted to set a breakpoint or perform any other basic trouble-shooting?

Duane
Hook'D on Access
MS Access MVP

RE: Mgs does not display

Also, there is a custom function or variable called "PaymentType".
Can you share what it is and where it is set to any value?

Have fun.

---- Andy

There is a great need for a sarcasm font.

RE: Mgs does not display

I hadn't noticed the line

CODE --> vba

PaymentType = PaymentType 

If you are referencing a control on a form or field in a form's recordsoutce, you should always use

CODE --> vba

Me.ControlName 

Duane
Hook'D on Access
MS Access MVP

RE: Mgs does not display

I would start with:

CODE

Dim bytMonths As Byte
MsgBox "PaymentType at this place is " & PaymentType
If PaymentType = 0 Then
... 
And see what will the message box display. I bet it is not 0

Have fun.

---- Andy

There is a great need for a sarcasm font.

RE: Mgs does not display

PaymentType = PaymentType is also not necessary since it does nothing.

RE: Mgs does not display

(OP)
Thanks all for responding. It has been quite a few years since I did any of this And forgive me, but am not familiar with TGML. The paymentType must be selected and only certain payments will be membership dues, therefore the Paid thru date will be updated. The other payment types do not affect membership status. What I do not understand is why this code works in an earlier version of Access and does not work in 2010.

RE: Mgs does not display

The suggestions provided are trying to find out what is not working and where it is not working. That is why people are asking about troubleshooting.
1. Is the code actually being called? You can check that by putting a message box at the top of the procedure. There are reasons it could stop being called such as the on before update event property no longer has "[event Procedure]" in the property.
2. So if it is being called is 0 actually being passed. Again the message box would tell this. If this is the default value it may be that after conversion the default value property of the table or form is no longer.
3. If zero is passed then it should call display message. But since you did not pass that code, there is no way to tell if there is a problem.

My guess is that there is no problem with the code, but payment type never equals zero. It is defaulting to null instead of zero. That is the reason for the message box to debug.

99.9% of the time code does not stop working when you change versions, and if it does you will know immediately. There is logic external to the code that has changed.

RE: Mgs does not display

TGML is as simple as formatting text in a word processor. Just select the text in your reply and then click a button above the input box. Use the button with the scroll and <> for your code. Always Preview your reply prior to clicking Submit Post.

I counted at least 4 questions and several observations from people trying to help you that you seemed to have ignored in your reply banghead.

Duane
Hook'D on Access
MS Access MVP

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close