troubleshooting Question

Checking for required fields, and updating unbound form

Avatar of Karen Schaefer
Karen SchaeferFlag for United States of America asked on
Microsoft Access
5 Comments1 Solution437 ViewsLast Modified:
I have an unbound form that opens up in add mode with certain required fields.  I need to check if the fields are null and if so have the system return the user back to the null field(s).  

Once all required fields contain data I need to update the data into the table.  This form opens in add mode.  I have tried using the bound recordsource but that wants to create a record that would later need to be deleted if the user does not complete the processing of the form.  So I am trying to use an unbound form without using a temp table..

I need to create a form that validates that all required fields contain data, then update the table(recordsource) with the data from the unbound form.  Am I on the right track?

Thanks,

Karen
Private Sub cmdApproval_Click()
 
   On Error GoTo cmdApproval_Click_Error
    For Each ctl In Me.Controls
        If ctl.Tag = "C" Then
            If IsNull(Me.ActiveControl) Then
                Call MsgBox("There is Data Missing.", vbExclamation Or vbDefaultButton1, "Warning")
                Me.ActiveControl.SetFocus
                Me.ActiveControl.BackColor = 128
                Me.ActiveControl.ForeColor = 16777215
                Exit Sub
            End If
        End If
    Next ctl
 
    Set rs = Currentdb.OpenRecordset("Select * from [Emergent Work]")
    If Not rs.EOF Then
       With rs
           .AddNew
           !Tech_Grp_Person = Me.Tech_Grp_Person
           !Task_Description = Me.Task_Description
           !Requested_by = Me.Requested_by
           !Work_Estimate = Me.Work_Estimate
           !Planned_Start = Me.Planned_Start
           !Planned_End = Me.Planned_End
           !ECD = Me.ECD
           !In_Support_of = Me.In_Support_of
           !Work_Authority = Me.Work_Authority
           !Status = 1
           .Update
       End With
    End If
        Set rs = Currentdb.OpenRecordset("Select Max(Seq_NO) as ID, Tech_Grp_Person from [Emergent Work]")
        Do Until rs.EOF
            gWR = rs.Fields("ID").Value
            Debug.Print rs.Fields("Tech_Grp_Person")
            gTP = rs.Fields("Tech_Grp_Person").Value
        Loop
    EmailMgmtApprReq
   
   On Error GoTo 0
   Exit Sub
 
cmdApproval_Click_Error:
 
    MsgBox "Error " & Err.Number & " (" & Err.Description & ") in procedure cmdApproval_Click of VBA Document Form_frmEmergentWork"
End Sub
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 5 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 5 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros