Results 1 to 8 of 8
  1. #1
    burrina's Avatar
    burrina is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Oct 2012
    Location
    Freeport,Texas
    Posts
    1,383

    If IsNull CustomerID Then Disable Subform

    I am trying to prevent users from entering a order without the correct fields filled in such as CustomerID.
    Here is my criteria; These fields must be filled in! CompanyOrderSubform is the name of the subform. Main form is named CompanySellInventory
    Company
    Customer
    Employee
    Shipping Method


    SubmittedBy
    OrderDate
    PurchaseOrderNumber

    Here is what I tried with no luck.
    If IsNull([CustomerID]) Then
    Me.CompanyOrderSubform.Enabled = False
    Else
    If IsNull([EmployeeID]) Then
    Me.CompanyOrderSubform.Enabled = False
    Else
    If IsNull([OrderDate]) Then
    Me.CompanyOrderSubform.Enabled = False
    If IsNull([PurchaseOrderNumber]) Then
    Me.CompanyOrderSubform.Enabled = False
    End If

    Of course my idea here is to disable the subform until the fields have been properly filled in.

  2. #2
    Rawb is offline Expert
    Windows XP Access 2000
    Join Date
    Dec 2009
    Location
    Somewhere
    Posts
    875
    The easiest thing to do is move the Subform out into its own Form. Then have a "Create Order" button that doesn't open the new Form unless all the criteria has been entered.

  3. #3
    alansidman's Avatar
    alansidman is offline Indifferent
    Windows 7 32bit Access 2010 32bit
    Join Date
    Apr 2010
    Location
    Steamboat Springs
    Posts
    2,536
    I would do it in reverse. In the Current Event, disable the subform or hide it. Then if all the fields are not null, make the subform enabled or visible. I would add a command button to open the subform. If the main form items are not completed then, a message that the subform cannot be opened until all fields are completed.

    Alan

    edit: or as Rawb described, use a separate form. But open it with a command button as we have both indicated.

  4. #4
    burrina's Avatar
    burrina is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Oct 2012
    Location
    Freeport,Texas
    Posts
    1,383

    Subform Visible if Checkbox is True

    If Me.Check176 = True Then 'Displays Products Form if Criteria is met.
    [OrderDetailsSubform].Visible = True
    Else
    [OrderDetailsSubform].Visible = False
    End If
    End If

    Why does this not work? Checkbox is named Check176 and Label is named Active
    Subform is named OrderDetailsSubform off main form OrderDetails
    Code run on OnCurrentEvent procedure.

    Ok, I deleted the Label and named the Checkbox Active still no luck.Here is screenshot
    Attached Thumbnails Attached Thumbnails SubformVisibleError.jpg  
    Last edited by burrina; 12-11-2012 at 05:03 PM. Reason: Explanation

  5. #5
    alansidman's Avatar
    alansidman is offline Indifferent
    Windows 7 32bit Access 2010 32bit
    Join Date
    Apr 2010
    Location
    Steamboat Springs
    Posts
    2,536
    I think that the issue is with your naming convention for the subform.

    Look at this link on subforms and referring to them.

    BTW: It is not good practice to name controls Check176. Six months from now you or someone else is doing some design updates. What will that mean to them. Give your controls names that will help you to follow what is going on in your code.

    Look at this link on naming conventions

    http://www.dhdurso.org/articles/acce...onventions.pdf

    In the long run, you will be happier if you follow a naming convention. I have gone back to db I built five years ago when I first started and its a real issue trying to figure out what I did in a couple of situations.

  6. #6
    burrina's Avatar
    burrina is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Oct 2012
    Location
    Freeport,Texas
    Posts
    1,383
    Thanks for the help. However, I renamed the form to frmOrderDetailsSubform and the code still does not work.

  7. #7
    burrina's Avatar
    burrina is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Oct 2012
    Location
    Freeport,Texas
    Posts
    1,383
    This solved the Problem. I know my db could use some restructuring but naming convention was not the problem. I will in the future be more careful with this though.

    Me.[Order Details Subform].[Form].Visible = False worked like a charm.

  8. #8
    alansidman's Avatar
    alansidman is offline Indifferent
    Windows 7 32bit Access 2010 32bit
    Join Date
    Apr 2010
    Location
    Steamboat Springs
    Posts
    2,536
    Glad you solved it. I apparantly did not attach the link that I thought I had on referencing sub forms. Just for future information.

    http://www.datapigtechnologies.com/f.../subform2.html

    but you got it Burrina. Nice show of figuring it out.

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

Similar Threads

  1. Replies: 1
    Last Post: 12-04-2012, 07:08 PM
  2. If IsNull Value, Then need to be Zero
    By burrina in forum Forms
    Replies: 2
    Last Post: 11-18-2012, 02:53 AM
  3. disable controls on a subform,
    By jaymin in forum Database Design
    Replies: 2
    Last Post: 06-23-2012, 07:05 AM
  4. Disable new entry in subform
    By mdewell in forum Forms
    Replies: 3
    Last Post: 01-05-2012, 02:38 PM
  5. Replies: 1
    Last Post: 08-06-2010, 07:50 PM

Tags for this Thread

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