Results 1 to 2 of 2
  1. #1
    JonathanT is offline Competent Performer
    Windows XP Access 2007
    Join Date
    Jan 2011
    Posts
    118

    VBA to find an empty field


    I'm trying to the VBA code to find the first empty value in a specific field of a recordset. This will run when a user clicks a button on a form. The record with the blank field will display on the form. Any help would be appreciated. I'm trying to avoid clicking on the Find option in the ribbon and typing in what I want find every time. I'd rather just click a button since this is a frequently repeated action

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,521
    scan the form's recordset to find the blank field...
    Code:
    dim fld as field
    
    for each fld in me.recordset.fields
      if isNull(fld.value) then
          controls(fld.name).setfocus   'assuming all text boxes have the same name as the fieldnames.(usu the default)
          exit sub
      endif
    next

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

Similar Threads

  1. Empty subform after find
    By Karyn in forum Forms
    Replies: 10
    Last Post: 04-29-2015, 08:06 AM
  2. Replies: 12
    Last Post: 10-22-2014, 02:11 PM
  3. Replies: 1
    Last Post: 09-20-2012, 03:15 PM
  4. Replies: 2
    Last Post: 04-23-2012, 10:13 PM
  5. Replies: 4
    Last Post: 11-20-2011, 01: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