Results 1 to 5 of 5
  1. #1
    tramp82 is offline Novice
    Windows XP Access 2000
    Join Date
    Oct 2011
    Posts
    13

    Subform Problem!

    Hi!

    I was wondering if someone can help me with a really small problem which has been driving me mad.



    I have a main form (Sales) with a subform (Sales Lines).

    In the Sales lines, I have a combo box (Machine ID) to choose the product and a quantity (Qty) text box.

    All I want to do is check that when I press the Save Order button on the main form, the subform has at least something in it.

    I have tried things like

    If Me.Do_Not_Use.Value = "" then
    MsgBox("Please Enter At Least One Model")
    End If

    But this does not recognise and the order line remains empty. It just saves the order with no order lines.

    Can someone help?!?!?!

    Richard

  2. #2
    hertfordkc is offline 18 year novice
    Windows XP Access 2007
    Join Date
    Mar 2011
    Posts
    481

    Does the Save Order button trigger your code example?

    If so, "me" refers to the main form. You may need to put a data check in the subform events and if the data is insufficient, use me.undo to unwind the update.

  3. #3
    tramp82 is offline Novice
    Windows XP Access 2000
    Join Date
    Oct 2011
    Posts
    13
    Quote Originally Posted by hertfordkc View Post
    If so, "me" refers to the main form. You may need to put a data check in the subform events and if the data is insufficient, use me.undo to unwind the update.
    I think I understand. But the problem is, I don't think the subform is being "triggered". For example. If I were to select something in the combobox and leave the Qty box empty, I do get a message saying the Qty box is empty and vice versa.

    Basically I want to it to include at least one record in that subform but I have no idea of how to make sure it does it?

    Richard

  4. #4
    Toyman is offline Competent Performer
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2011
    Posts
    233
    Quote Originally Posted by tramp82 View Post
    I think I understand. But the problem is, I don't think the subform is being "triggered". For example. If I were to select something in the combobox and leave the Qty box empty, I do get a message saying the Qty box is empty and vice versa.

    Basically I want to it to include at least one record in that subform but I have no idea of how to make sure it does it?

    Richard
    I am assuming your main form, "Sales" is unbound, and that is why you are using a "save" button to save the record. If this is so, put this code on the "save" button right before it initiates the "save" codes.

    Dim sMacID as Integer 'assuming the Machine ID is a number field. If it is a text field change the declearation to "string"
    sMacID = Nz(Me![Sales Lines].Form![Machine ID],0)
    if sMacID = 0 then 'no machine id or no record entered
    Msgbox "You must enter at least one sales line", vbInformation, "No Sales Entered"
    Me![Sales Lines].Form![Machine ID].SetFocus 'sets the focus to the mac ID field
    Exit Sub 'exits the code
    End if

  5. #5
    tramp82 is offline Novice
    Windows XP Access 2000
    Join Date
    Oct 2011
    Posts
    13
    Quote Originally Posted by Toyman View Post
    I am assuming your main form, "Sales" is unbound, and that is why you are using a "save" button to save the record. If this is so, put this code on the "save" button right before it initiates the "save" codes.

    Dim sMacID as Integer 'assuming the Machine ID is a number field. If it is a text field change the declearation to "string"
    sMacID = Nz(Me![Sales Lines].Form![Machine ID],0)
    if sMacID = 0 then 'no machine id or no record entered
    Msgbox "You must enter at least one sales line", vbInformation, "No Sales Entered"
    Me![Sales Lines].Form![Machine ID].SetFocus 'sets the focus to the mac ID field
    Exit Sub 'exits the code
    End if
    yOOOOOOOOOOU LEGEND!

    Thanks so much! Closing thread now )

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

Similar Threads

  1. Form / subform problem
    By ksmith in forum Programming
    Replies: 5
    Last Post: 08-30-2011, 07:33 AM
  2. Subform Problem
    By nchesebro in forum Forms
    Replies: 7
    Last Post: 08-03-2011, 05:24 PM
  3. form/subform reference problem
    By dbertanjoli in forum Forms
    Replies: 1
    Last Post: 01-10-2011, 03:31 PM
  4. Replies: 2
    Last Post: 06-14-2010, 03:25 PM
  5. problem with subform
    By dimension in forum Forms
    Replies: 1
    Last Post: 05-28-2009, 05:32 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