Live Chat & Podcast at 1:00PM Eastern on Sunday!
There's no such thing as a stupid question, but they're the easiest to answer.
JoinTour
Login
Search
Tag Cloud
access acer asus bios bsod computer crash desktop driver drivers error ethernet excel freeze gaming gpu hard drive hardware hdmi internet laptop malware memory monitor motherboard netgear network printer problem ram registry router security slow software sound trojan ubuntu 11.10 uninstall usb video virus vista wifi windows windows 7 windows 7 32 bit windows 7 64 bit windows xp wireless
Search
Search for:
Tech Support Guy Forums > Software & Hardware > Business Applications >
Solved: Keeping a Comment with only blank spaces from creating a record in MS Access

Reply  
Thread Tools
jlathem's Avatar
Computer Specs
Junior Member with 1 posts.
 
Join Date: Jul 2010
Experience: Intermediate
28-Jul-2010, 07:36 PM #1
Solved: Keeping a Comment with only blank spaces from creating a record in MS Access
Can anyone suggest how I can keep a comment record from being created if the “Comment” text box is blank or only has blank spaces in the text box?

Is there a VB script or something??
HiTechCoach's Avatar
Computer Specs
Member with 145 posts.
 
Join Date: Jul 2010
Location: Oklahoma
Experience: Microsoft MVP - Access
29-Jul-2010, 12:50 AM #2
Quote:
Originally Posted by jlathem View Post
Can anyone suggest how I can keep a comment record from being created if the “Comment” text box is blank or only has blank spaces in the text box?

Is there a VB script or something??
Note: Access uses VBA, not VB script, internally

In the form's Before Update event use something like this:

Code:
Private Sub Form_BeforeUpdate(Cancel As Integer)

 Cancel = False


' perform data validation
If Len(Trim(Nz(Me.txtComment,""))) < 1 Then

   MsgBox "You must enter a comment.", vbCritical, "Data entry error..."
      
   Cancel = True


End If


If Not Cancel Then
  ' passed the validation process

    If Me.NewRecord Then
        If MsgBox("Data will be saved, Are you Sure?", vbYesNo, "Confirm") = vbNo Then
            Cancel = True
        Else
            ' run code for new record before saving
        
        End If
    
    
    Else
        If MsgBox("Data will be modified, Are you Sure?", vbYesNo, "Confirm") = vbNo Then
            Cancel = True
        Else
           ' run code before an existing record is saved
           ' example: update date last modified
            
        End If
    End If

End If


' if the save has been canceled or did not pass the validation , then ask to Undo changes
If Cancel Then

    If MsgBox("Do you want to undo all changes?", vbYesNo, "Confirm") = vbYes Then
        Me.Undo

    End If
    
End If



End Sub
Reply

THIS THREAD HAS EXPIRED.
Are you having the same problem? We have volunteers ready to answer your question, but first you'll have to join for free. Need help getting started? Check out our Welcome Guide.

Search Tech Support Guy

Find the solution to your
computer problem!




Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
WELCOME TO TECH SUPPORT GUY! Are you looking for the solution to your computer problem? Join our site today to ask your question -- for free! Our site is run completely by volunteers who want to help you solve your computer problems. See our Welcome Guide to get started.
Thread Tools


Similar Threads
Title Thread Starter Forum Replies Last Post
MS Access 2003 - OLE Server Problem IMTanuki Business Applications 8 25-Mar-2010 09:44 PM
Solved: Prompt for user password in MS Access vba ctwest Software Development 2 16-Mar-2010 02:05 PM
Solved: MS Access 2003, Update One Field in Most Recent Record YoMamma Business Applications 2 07-Jul-2009 12:36 PM
Symentec email scanner taking long time to send Excel attachments in MS Outlook 2003 sajid974 Business Applications 0 18-Aug-2008 04:18 AM
How to Populate Data from other fields in MS ACCESS 2003 Pc civic Business Applications 0 13-Mar-2007 02:29 PM


Facebook Facebook Twitter Twitter TechGuy.tv TechGuy.tv Mobile TSG Mobile
You Are Using:
Server ID
Advertisements do not imply our endorsement of that product or service.
All times are GMT -4. The time now is 01:58 AM.
Copyright © 1996 - 2011 TechGuy, Inc. All rights reserved.

Powered by Cermak Technologies, Inc.