Results 1 to 8 of 8
  1. #1
    daversb is offline Novice
    Windows 7 Access 2007
    Join Date
    Nov 2010
    Posts
    6

    VBA Issue with Command

    Hi all,

    I have a database that I manage (front end / back end), was originally access 97, now have migrated to access 2007!!!

    When posting an invoice on a form to create a transaction record, the accounting rep will press a "post" button, at that point, it runs a macro, that is supposed to create a transaction record.

    Problem is though, since moving to access 2007, no-workie



    I can provide the code, but in the end not sure where to start!!! Tried (what i think) everything.

  2. #2
    NTC is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    Nov 2009
    Posts
    2,392
    There is nothing in that code stack that jumps out as not valid in Access2007.

  3. #3
    SteveH2508 is offline Competent Performer
    Windows XP Access 2007
    Join Date
    Sep 2010
    Location
    Chelsea, London, England
    Posts
    117
    1. Is the database in a Trusted Location?
    2. You might want to disambiguate your DAO object variables e.g. Dim rs as DAO.Recordset etc..

  4. #4
    orange's Avatar
    orange is online now Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,726
    The way you have Dimmed Y, RowSeperator will make them Variants (not an issue but that's the default).
    As has been mentioned, I suggest you use DAO. on the recordset
    You might add an Option Explicit in your procedures to force variables to be Dimmed. That way you'll know the datatypes.

    This line is commented out
    'If Forms![Orders]![Orders Subform].Form![PartCode] = "901" Then
    ' Me!TaxRefund = Forms![Orders]![Orders Subform].Form![UnitPrice]
    ' End If
    Don't know if that's important, just noting it.

    In Function PostOrder where the Addnew is located, I would add some

    Debug.print statement(s) to see exactly what the values of these fields is
    R!PostDate = Date
    R!TransType = "Order"
    R!TransAmount = Amount ' Order Amount posted as positive.
    'If Amount < 0 Then R!CreditAmount = ([Amount] * (-1))
    R!OrderID = OrderID
    R!CustomerID = CustomerID

    Also, there are lines commented out... Why??

  5. #5
    daversb is offline Novice
    Windows 7 Access 2007
    Join Date
    Nov 2010
    Posts
    6
    understood that there are a number of issues with the database having commented out sections, etc.

    The database was developed before I knew what access was (97), now 2011 access 2007 file format that I have slowly migrated, but there seems to be this lingering issue with being able to post the invoices and have the transaction record created (that is what the code does).

    When i open the 2003 file format it works with no issue!!! Of Course a number of other issues exist with the 2003 :/

  6. #6
    orange's Avatar
    orange is online now Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,726
    So it works in 2003, but not in 2007?
    I didn't see anything in the code that would make it not work, but did find a few things and noted them. I don't have 2007.

  7. #7
    daversb is offline Novice
    Windows 7 Access 2007
    Join Date
    Nov 2010
    Posts
    6
    that's what i'm saying it's very strange....

    this keeps on coming up (poor design on the previous party's part) and is getting to the point where I am probably going to have to create a new database (totally new), and just let the couple of people that actually post invoices have a copy of the 2003 to make it swing...

    I will be sure to ask more questions of you when i wrap my head around redesigning the system

  8. #8
    orange's Avatar
    orange is online now Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,726
    One thing I did notice was there there is no error trapping or the error trapping was commented out.

    THere is a free utility called MZTools for vba. It is used by many and has many useful tools. One will build error trapping for you within a procedure with the click of a button.
    It also has feature to show unused code; create consistent headers for procs and modules. If you don't have it, it's well worth getting and using.
    Here's the link
    http://www.mztools.com/v3/mztools3.aspx

    Good luck with your project.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. command buttons
    By nashr1928 in forum Forms
    Replies: 23
    Last Post: 10-15-2010, 04:09 PM
  2. Command buttons
    By maintt in forum Forms
    Replies: 3
    Last Post: 08-03-2010, 09:52 AM
  3. Replies: 1
    Last Post: 07-27-2010, 02:27 PM
  4. Command button issue
    By sloppysly in forum Forms
    Replies: 8
    Last Post: 06-15-2009, 12:07 PM
  5. command button to filter a subform issue -
    By countdrako in forum Forms
    Replies: 1
    Last Post: 12-09-2005, 11:58 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums