Page 1 of 2 12 LastLast
Results 1 to 15 of 16
  1. #1
    Jasonmayak is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Jul 2014
    Posts
    7

    Need help with record validation

    Hi I'm new to access so this may be a quick fix for someone but not me. I need to setup this table so that if the "current status" field is set to Empty than both the "Material" and "Resource" fields are cleared out of any information. Right now the Material, resource and current status fields are all drop downs with the information being pulled from other tables setup just to standardize the data. My problem is that currently any bin ID can show material and resource in it while its status is empty and it throws off my queries. Thanks for any help.
    Click image for larger version. 

Name:	Untitled.jpg 
Views:	12 
Size:	38.2 KB 
ID:	17499


  2. #2
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2013
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    You're not using "Lookup" Fields are you? http://access.mvps.org/access/lookupfields.htm

  3. #3
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,626
    Do you want to actually delete the data from the fields? That can be done with an UPDATE sql action.

    I am confused - the example shows the Material and Resource fields are empty when Status says empty. If the issue is that status can be changed to Empty from one of the other 3 values and therefore data needs to be removed from Material and Resource fields, that can be accomplished with code in Status combobox AfterUpdate event on form.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  4. #4
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows 7 32bit Access 2003
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,610
    AFAIK a table has no events so this would need to be done in a form bound to the table. (Users should never be working directly with tables anyway.)
    You would just need a bit of code in the After Update event of the control on the form that is bound to the "Current Status" field that evaluates it's own value and if that value is equal to "Empty" then set the value of the controls bound to "Material" and "Resource" to Null.
    Post back if you need help with the actual code.
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  5. #5
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,626
    Bob, just for reference - Access 2010 introduced Data Macros which allow event code to be associated with tables.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  6. #6
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows 7 32bit Access 2003
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,610
    Quote Originally Posted by June7 View Post
    Bob, just for reference - Access 2010 introduced Data Macros which allow event code to be associated with tables.
    Thanks for the info June. Sound like another bad idea to me though.
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  7. #7
    Jasonmayak is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Jul 2014
    Posts
    7

    Thanks Bob.

    Bob,
    That makes perfect sense to me I just do not get the coding yet if you have an example I would appreciate it.

    Thanks,
    JM
    Quote Originally Posted by Bob Fitz View Post
    AFAIK a table has no events so this would need to be done in a form bound to the table. (Users should never be working directly with tables anyway.)
    You would just need a bit of code in the After Update event of the control on the form that is bound to the "Current Status" field that evaluates it's own value and if that value is equal to "Empty" then set the value of the controls bound to "Material" and "Resource" to Null.
    Post back if you need help with the actual code.

  8. #8
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,626
    In VBA, like:

    If Me!Status = "Empty" Then
    Me!Material = Null
    Me!Resource = Null
    End If
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  9. #9
    Jasonmayak is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Jul 2014
    Posts
    7

    Thanks but its not working.

    Quote Originally Posted by June7 View Post
    In VBA, like:

    If Me!Status = "Empty" Then
    Me!Material = Null
    Me!Resource = Null
    End If

    I appreciate the help. I attempted to plug this code into an event procedure under my only form in my database, 1st on "After update" then on "on current" I don't get any error messages from the code but it simply does not update my table or form at all. And I am saving it after I copy the code into place so I know its there. Is there anyways I can accomplish this from the table directly by using a record validation? I would really like to see my form react by clearing the material and resource fields when empty is selected in the current status field. In the table that contains the options for the material and resource fields I have created an additional record with no data in it (blank) and if I could just get the form to recognize that empty is in the current status field and to automatically swap the data from the material and resource field over to these blank options that would be ideal.
    Click image for larger version. 

Name:	3.jpg 
Views:	11 
Size:	222.3 KB 
ID:	17528Click image for larger version. 

Name:	1.jpg 
Views:	11 
Size:	44.7 KB 
ID:	17525Click image for larger version. 

Name:	2.jpg 
Views:	11 
Size:	31.7 KB 
ID:	17529Click image for larger version. 

Name:	4.jpg 
Views:	11 
Size:	20.8 KB 
ID:	17527Click image for larger version. 

Name:	5.jpg 
Views:	11 
Size:	77.5 KB 
ID:	17526

  10. #10
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,626
    Use the combobox AfterUpdate event.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  11. #11
    Jasonmayak is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Jul 2014
    Posts
    7
    In that combo box is "Event Procedure" and a Macro called "Close report command" which I created to exit out of a report within the database. Should there be something else there? What I have done is use the combo box to select event procedure and then clicked the button with the 3 dots to the right and that that is where I copied that code into. Sorry if I'm making this more difficult than it has to be. I appreciate your help.

  12. #12
    Jasonmayak is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Jul 2014
    Posts
    7
    Also I am actually using access 2010 right now.

  13. #13
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,626
    If the combobox AfterUpdate event property says [Event Procedure] then you have VBA code. Maybe the procedure is calling a macro (I don't use macros) called "Close report command" but this is still a VBA procedure. Add the suggested code into the procedure behind the macro call.

    However, I would think the form AfterUpdate event should work, which is what is shown in the image.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  14. #14
    Jasonmayak is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Jul 2014
    Posts
    7
    I'm not sure why this code is not working. I wonder if there is an issue with how these field get their information. I have a main table (injbinmanagement) with these fields setup there as a lookup field pulling data from a different table each. So Currentstatus has a table as well as Material and Resource.

    Quote Originally Posted by June7 View Post
    If the combobox AfterUpdate event property says [Event Procedure] then you have VBA code. Maybe the procedure is calling a macro (I don't use macros) called "Close report command" but this is still a VBA procedure. Add the suggested code into the procedure behind the macro call.

    However, I would think the form AfterUpdate event should work, which is what is shown in the image.

  15. #15
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,626
    But are you saving Material and Resource keys into injbinmanagement?

    If you want to provide db for analysis, follow instructions at bottom of my post.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

Page 1 of 2 12 LastLast
Please reply to this thread with any new information or opinions.

Similar Threads

  1. Record-Level Validation in Tables
    By Merf in forum Access
    Replies: 1
    Last Post: 07-16-2013, 02:00 PM
  2. Validation
    By stefan200593 in forum Access
    Replies: 1
    Last Post: 03-25-2013, 02:32 PM
  3. Age validation
    By dolovenature in forum Programming
    Replies: 5
    Last Post: 09-01-2012, 09:21 AM
  4. validation
    By slimjen in forum Forms
    Replies: 6
    Last Post: 10-12-2011, 01:19 PM
  5. Record Submit Validation Rule in Form
    By agent- in forum Programming
    Replies: 7
    Last Post: 05-24-2011, 04:03 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