Results 1 to 8 of 8
  1. #1
    fitshase is offline Novice
    Windows XP Access 2007
    Join Date
    Jul 2011
    Posts
    4

    BeforeUpdate in a Form in Datasheet view

    Hi,

    I'm new to this so please be kind

    I am helping to develop a database ("Project DB") at work to help track dates for works on various sites (various actual dates and a selected few forecast dates for major milestones). I have the tables set up OK and I've created some forms as well to make it easier to input the data.

    On one of the forms (in form view), I have the BeforeUpdate function assigned to the fields related to forecast dates. When a forecast date is updated, "Yes" is inserted into a field called "ForecastsUpdated":-

    Private Sub Survey_Forecast_BeforeUpdate(Cancel As Integer)
    ForecastsUpdated = "Y"
    End Sub




    Private Sub Planning_Forecast_BeforeUpdate(Cancel As Integer)
    ForecastsUpdated = "Y"
    End Sub


    Private Sub Completion_Forecast_BeforeUpdate(Cancel As Integer)
    ForecastsUpdated = "Y"
    End Sub

    This works fine on the form in form view but if I put this function on a field in a form in datasheet view I get an error:-

    The expression Before Update you entered as the event property setting produced the following error: A problem occurred while Project DB was communicating with the OLE server or ActiveX Control.

    * The expression may not result in the name of a macro, the name of a user-defined function, or [Event Procedure]
    * There may have been an error evaluating the function, event, or macro

    Can you let me know what I am doing wrong?

    Cheers

  2. #2
    SoftwareMatters is offline Access VBA Developers
    Windows XP Access 2003
    Join Date
    Mar 2009
    Location
    Dorset
    Posts
    274
    Unless there is a good reason not to I would place this code on the AfterUpdate and also add a check that the field isn't blank as follows:

    Private Sub Survey_Forecast_AfterUpdate
    If not isnull(me!Survey_Forecast) then
    me!ForecastsUpdated = "Y"
    End If
    End Sub

    NB: I don't know if this will fix your issue.

  3. #3
    fitshase is offline Novice
    Windows XP Access 2007
    Join Date
    Jul 2011
    Posts
    4
    JD,

    Thanks for the prompt reply. Unfortunately that doesn't solve the problem. I no longer get the error message but I also don't get the "Y" in the ForecastsUpdated field.

    Cheers

  4. #4
    fitshase is offline Novice
    Windows XP Access 2007
    Join Date
    Jul 2011
    Posts
    4
    I've figured it out (eventually!). It appears to be because that particular form was based on a query instead of a table. For some reason the person who set up the database created a query which pulled all the data from the table and then built a form based on the query. I've bypassed the query part (since it pulled all records from the table so was no different to the table) and it works.


    How do I mark this as "Solved"?

  5. #5
    SoftwareMatters is offline Access VBA Developers
    Windows XP Access 2003
    Join Date
    Mar 2009
    Location
    Dorset
    Posts
    274
    How do I mark this as "Solved"?
    Don't know if you can - same thing has been asked here: http://www.access-programmers.co.uk/....php?p=1085266

  6. #6
    Matrix's Avatar
    Matrix is offline Admin
    Windows XP Access 2003
    Join Date
    Jan 2005
    Posts
    519
    Quote Originally Posted by fitshase View Post
    How do I mark this as "Solved"?
    https://www.accessforums.net/forum-s...lved-1828.html

  7. #7
    SoftwareMatters is offline Access VBA Developers
    Windows XP Access 2003
    Join Date
    Mar 2009
    Location
    Dorset
    Posts
    274
    Oops my link was for Access-programmers. Doh!
    Thanks Matrix.

  8. #8
    fitshase is offline Novice
    Windows XP Access 2007
    Join Date
    Jul 2011
    Posts
    4
    Thank you both. I looked everywhere but must have overlooked it.

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

Similar Threads

  1. Code to call Split Form View Datasheet
    By ahightower in forum Programming
    Replies: 1
    Last Post: 07-28-2011, 04:57 PM
  2. Datasheet view in tab only
    By cdzajp in forum Forms
    Replies: 1
    Last Post: 06-22-2011, 12:44 PM
  3. Form opens table in datasheet view
    By franklbl in forum Forms
    Replies: 9
    Last Post: 03-23-2011, 09:43 PM
  4. Datasheet View
    By Evgeny in forum Programming
    Replies: 6
    Last Post: 04-28-2010, 10:17 AM
  5. Form - Datasheet View
    By kalove in forum Forms
    Replies: 0
    Last Post: 06-20-2007, 11:29 AM

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