Results 1 to 4 of 4
  1. #1
    Join Date
    Dec 2010
    Posts
    2

    Check if fields are empty

    Hey everyone.

    I'm sorry if this has been answered already, but I couldn't find a previous thread about this.

    Anyways, I have a form which works fine, but the only point I need fixed is that it should check if all fields are filled when I hit the 'Send' button, and if not it should return a message saying so, and allow the user to fill up the remaining fields. I've tried a few ways but none seem to work properly.

    Thanks in advance
    Regards,
    Sebastian

  2. #2
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 Access 2010 (version 14.0)
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Sebastian,
    Welcome to the Forum. Here's a stub of code that might be of use in the BeforeUpdate event of the Form:
    Code:
    Dim ctl As Control
    For Each ctl In Me.Controls
    If ctl.ControlType = acComboBox Or ctl.ControlType = acTextBox Then
       If Len(ctl.Value & "") = 0 Then
          '..This control is empty
          '...do what you want!
       End If
    End If
    Next ctl
    I do not know your VBA skill level so if this is not enough then post back for additional assistance.

  3. #3
    Join Date
    Dec 2010
    Posts
    2
    Thanks for you help

    Though my VBA skills are quite lacking. I've pretty much just started working with it, and only know a few basic things, like how to make a message box. Anyways, the current code for the Send button is this:

    Private Sub versturen_Click()
    On Error GoTo Err_versturen_Click


    DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70

    LResponse = MsgBox("De patiënt is toegevoegd. Wilt u nog een patiënt toevoegen?", vbYesNo, " ")

    If LResponse = vbYes Then
    DoCmd.GoToRecord , , acNext
    Else
    DoCmd.Close
    End If


    Exit_versturen_Click:
    Exit Sub

    Err_versturen_Click:
    DoCmd.GoToRecord , , acNext
    Resume Exit_versturen_Click

    End Sub

  4. #4
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 Access 2010 (version 14.0)
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Are you aware that unless you take extrordinary steps, Access will save a Dirty record if you try and move off of the record for *any* reason, including closing the form?

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

Similar Threads

  1. Choose whether to display empty fields in a report
    By exoticdisease in forum Access
    Replies: 1
    Last Post: 08-18-2010, 09:12 AM
  2. saving records without null or empty fields
    By amber mara in forum Access
    Replies: 1
    Last Post: 05-05-2010, 02:34 PM
  3. Copying into empty fields until...
    By cochi30 in forum Programming
    Replies: 8
    Last Post: 06-07-2009, 07:38 AM
  4. Hiding fields that contains empty records
    By sakthivels in forum Reports
    Replies: 4
    Last Post: 05-27-2009, 07:06 AM
  5. How to get rows with empty fields as well?
    By Orabidoo in forum Queries
    Replies: 10
    Last Post: 04-24-2009, 06:08 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