Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Access Discussion of Microsoft Access database design and programming. See also the forums for Access ASP and Access VBA.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old October 27th, 2005, 01:04 PM
Authorized User
 
Join Date: Apr 2005
Location: , , USA.
Posts: 56
Thanks: 0
Thanked 0 Times in 0 Posts
Default Yes No Message box

Hello,

I use a command button to post an invoice amount. I would like to prevent accidental overwriting of a current invoice amount. This code overwrites the amount even after clicking “No”. I would like the cancel the action when “No’ is clicked. Please help!


Private Sub PostInvoice_Click()
On Error GoTo Err_PostInvoice_Click

If IsNull(InvoiceBalance) Then
    [InvoiceTotal] = Me.InvoiceTotal1
    [InvoiceBalance] = Me.InvoiceTotal1
    [DueDate] = Me.InvoiceDate + 30

Else
    MsgBox "You are about to overwrite the current invoice balance"

MsgBox "Are you sure you want to overwrite the current invoice amount", vbYesNo
        If vbYes Then
            [InvoiceTotal] = Me.InvoiceTotal1
            [InvoiceBalance] = Me.InvoiceTotal1
            [DueDate] = Me.InvoiceDate + 30
        Else
            Exit Sub

        End If

End If


Exit_PostInvoice_Click:
    Exit Sub

Err_PostInvoice_Click:
    MsgBox Err.Description
    Resume Exit_PostInvoice_Click

End Sub


D. Bartelt
__________________
D. Bartelt
Reply With Quote
  #2 (permalink)  
Old October 27th, 2005, 01:09 PM
Friend of Wrox
 
Join Date: Jan 2005
Location: Kansas City, Missouri, USA.
Posts: 471
Thanks: 0
Thanked 1 Time in 1 Post
Default

Howdy D!
How you doing? Switch your code to this:

myresponse = MsgBox("Are you sure you want to overwrite the current invoice amount", vbYesNo)

If myresponse = vbYes Then

Kevin


dartcoach
Reply With Quote
  #3 (permalink)  
Old October 27th, 2005, 01:10 PM
Friend of Wrox
 
Join Date: Oct 2004
Location: Clinton, UT, USA.
Posts: 564
Thanks: 0
Thanked 4 Times in 4 Posts
Default

Hi,

Try this... What is happening is that you are not capturing the users answer from the Message Box

Original Code


MsgBox "Are you sure you want to overwrite the current invoice amount", vbYesNo
        If vbYes Then
            [InvoiceTotal] = Me.InvoiceTotal1
            [InvoiceBalance] = Me.InvoiceTotal1


New Code


intResponse = MsgBox ("Are you sure you want to overwrite the current invoice amount", vbYesNo+vbQuestion)
'+vbQuestion just adds a Question Mark to the MsgBox
If intResponse = vbYes Then
    [InvoiceTotal] = Me.InvoiceTotal1
    [InvoiceBalance] = Me.InvoiceTotal1
    .......


Hope that helps,

Mike

Mike
EchoVue.com
Reply With Quote
  #4 (permalink)  
Old October 27th, 2005, 01:47 PM
Authorized User
 
Join Date: Apr 2005
Location: , , USA.
Posts: 56
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi dartcoach,

I'm doing fine, how 'bout yourself? Thank you for the help. The code worked after I added "Dim myreponse As Integer" to the beginning of the code.

I'm almost done with the accounts receivable database. Just have to figure out how to update the invoice balance field in tblInvoices from the payments subform. The payments subforms' recordsource is tblpayments. Also have to create Aged Receivables forms and reports yet. After those, it's ready to go.

Take care!




D. Bartelt
Reply With Quote
  #5 (permalink)  
Old October 27th, 2005, 08:30 PM
Friend of Wrox
 
Join Date: Jan 2005
Location: Kansas City, Missouri, USA.
Posts: 471
Thanks: 0
Thanked 1 Time in 1 Post
Default

D,

Are the tblpayments and tblinvoices related by invoice number?

If they are, then whenever you enter a payment, you would want to recalculate the total payments made, then, update current balance of the invoice where invoice numbers are equal.

Make sense?

Kevin

dartcoach
Reply With Quote
  #6 (permalink)  
Old October 28th, 2005, 07:01 AM
Friend of Wrox
Points: 4,007, Level: 26
Points: 4,007, Level: 26 Points: 4,007, Level: 26 Points: 4,007, Level: 26
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Lansing, Michigan, USA.
Posts: 1,151
Thanks: 2
Thanked 14 Times in 14 Posts
Send a message via ICQ to SerranoG Send a message via AIM to SerranoG
Default

Code:
    Dim intUpdate as Integer

    If IsNull(Me.InvoiceBalance) Then
        intUpdate = vbYes
    Else
        intUpdate = MsgBox("You are about to overwrite the current invoice balance.  Are you sure you want to do this?", vbQuestion + vbYesNo, "Overwrite Balance?")
    End If

    If intUpdate = vbYes Then
        Me.InvoiceTotal = Me.InvoiceTotal1
        Me.InvoiceBalance = Me.InvoiceTotal1
        Me.DueDate = DateAdd("d", 30, Me.InvoiceDate)
    End If

Greg Serrano
Michigan Dept. of Environmental Quality, Air Quality Division
Reply With Quote
  #7 (permalink)  
Old October 28th, 2005, 08:05 AM
Authorized User
 
Join Date: Apr 2005
Location: , , USA.
Posts: 56
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Kevin,

Yes the tables are related by InvoiceID. InvoiceID is the PK in tblInvoices.

Thanks,

Don

D. Bartelt
Reply With Quote
  #8 (permalink)  
Old October 28th, 2005, 08:16 AM
Authorized User
 
Join Date: Apr 2005
Location: , , USA.
Posts: 56
Thanks: 0
Thanked 0 Times in 0 Posts
Default

echovue & SerranoG,

Thanks for your input. I am absorbing all the help I get.

Thanks again!

Don

D. Bartelt
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Message box basie Classic ASP Basics 1 September 4th, 2008 01:09 PM
Message box in C# shikha09 C# 0 November 28th, 2006 01:24 AM
how to use message box? andy hee ASP.NET 1.0 and 1.1 Basics 1 April 18th, 2006 04:53 AM
message box nalla ASP.NET 2.0 Professional 4 December 23rd, 2005 03:00 AM



All times are GMT -4. The time now is 01:01 PM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.