Results 1 to 2 of 2
  1. #1
    Join Date
    Jun 2015
    Location
    Wales. Land of the sheep.
    Posts
    1,228

    data validation on subform

    The code I'm working with is below, I only want to check that some data is entered into any field of a subform. Maybe recordset should be used?

    It seems to skip past this causing no error where there should be one:



    Code:
    If IsNull(Me.Invoice_Generator2.Form.Controls(Inv_Quantity)) = True Then

    Full code listed below. The date validation works ok.
    Code:
    Private Sub Command4_Click()
    
    On Error GoTo HandleError
    '''''''''''''
    If IsNull(Me.Invoice_Generator2.Form.Controls(Inv_Quantity)) = True Then
    MsgBox "Enter at least 1 line value."
    Exit Sub
    Else
    End If
    
    '''''''''''''
    If IsNull(Date_on_invoicetxt) = True Then
    MsgBox "Please enter a date for the invoice."
    Exit Sub
    Else
    End If
    
    DoCmd.SetWarnings False
    DoCmd.RunCommand acCmdSaveRecord
    DoCmd.OpenQuery "append invoice lines"
    DoCmd.OpenQuery "Update_invoice_issue"
    DoCmd.Close acForm, "New Invoice", acSaveYes
    
    DoCmd.SetWarnings True
    HandleExit:
        Exit Sub
    HandleError:
        MsgBox Err.Description
        Resume HandleExit
    
    End Sub
    any help appreciated. its probably simple but I'm very rusty.

  2. #2
    Join Date
    Jun 2015
    Location
    Wales. Land of the sheep.
    Posts
    1,228
    No need to panic guys!

    It was as simple as: If IsNull(Me.Invoice_Generator2.Form.Inv_Quantity) = True Then

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

Similar Threads

  1. Data validation on each row.
    By Homegrownandy in forum Forms
    Replies: 40
    Last Post: 05-22-2017, 02:31 AM
  2. Replies: 1
    Last Post: 02-11-2015, 07:45 AM
  3. Subform control validation
    By Xarkath in forum Access
    Replies: 1
    Last Post: 11-04-2014, 04:44 PM
  4. Replies: 14
    Last Post: 01-07-2014, 04:20 PM
  5. Validation in main and subform
    By crxftw in forum Forms
    Replies: 3
    Last Post: 09-03-2011, 07:01 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