Results 1 to 7 of 7
  1. #1
    5 Star Lounger
    Join Date
    Jan 2001
    Posts
    1,119
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Macro (Access 97)

    Here I am again - trying to do something that seems obvious but apparently not. On the After Update event of date field on a form I attached a macro. In the condition area I have [Bkcomdate] < [dateindept]. Then I have cancelEvent, MsgBox (which says Book Complete Date must be greater than Date in Department), and gotocontrol (bkcomdate). No matter what date I put in bkcomdate, that message appears. What condition should I put to make this happen. Thank you for your time and patience.

  2. #2
    2 Star Lounger
    Join Date
    Jun 2002
    Posts
    117
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Macro (Access 97)

    Post your Macro to the list.

    Right mouse click on your macro

    Left mouse click on Save As/Export

    Select "Save as Visual Basic Module"

    Select Convert

    Click on the Modules Tab

    Copy and post the contents of the "Converted Macro- Your Macro Name"

  3. #3
    3 Star Lounger
    Join Date
    Jan 2001
    Location
    Edmonton, Alberta, Canada
    Posts
    326
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Macro (Access 97)

    As implied by accdb, code is easier for us to help you with than macros. However, one this to keep in mind is that a null value always compares false against any other value. So, check [dateindept]. If it is null at the time you are entering the data into [bkcomdate], then you'll get your validation message.

    If that's the problem, either ensure that [bkcomdate] is not null, or use something like [dateindept] is null or [bkcomdate]<[dateindept]

  4. #4
    5 Star Lounger
    Join Date
    Jan 2001
    Posts
    1,119
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Macro (Access 97)

    OK, how would I write code for the after update event of the field bkcomdate so that if that date is not greater than the dateindept a message appears stating that the book complete date must be greater than the date in department. I thought a macro would be easier for me to write than code.

  5. #5
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Macro (Access 97)

    You need to use the BeforeUpdate event, for the AfterUpdate event can't be canceled.

    Your code could lool like this:

    Private Sub txtBkComDate_BeforeUpdate(Cancel As Integer)
    If txtBkComDate < txtDateInDept Then
    MsgBox "BkComDate must be on or after DateInDept."
    Cancel = True
    End If
    End Sub

  6. #6
    Platinum Lounger
    Join Date
    Dec 2001
    Location
    Melbourne, Australia
    Posts
    4,594
    Thanks
    0
    Thanked 27 Times in 27 Posts

    Re: Macro (Access 97)

    Macros are possibly easier to write than VBA code, but you should get used to writing VBA code, it's not hard after a while. Plus code has advantages over macros and you definitely have more control with VBA code.
    Pat <img src=/S/smile.gif border=0 alt=smile width=15 height=15>

  7. #7
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Macro (Access 97)

    Well-written macros are not much easier than VBA code and can be harder because you spend a lot of time beating your head against the limitations of macros.
    Charlotte

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •