Microsoft Access Forums

Go Back   Microsoft Access Forums > Access Forums > Forms

Reply
 
LinkBack Thread Tools Display Modes
  #1  
Old 02-08-2010, 11:03 PM
cwwaicw311 cwwaicw311 is offline Windows XP Access 2003 (version 11.0)
Advanced Beginner
 
Join Date: Feb 2010
Posts: 75
cwwaicw311 is on a distinguished road
Default Check for NULL text box when clicking save on form

Hi, is there feature whereby when i click on the save button, if there is a textbox which is empty or null the form would not save??

I also have another question is that, is there somehow when i open the form page which i have created, normally the when we open the form it would appear the first record of the form (for example 1 of 6). So my question is that is there any setting when i open the form i would be a new record page where i can straight enter information into the form without clicking to a new page??
Reply With Quote
  #2  
Old 02-09-2010, 12:15 AM
maximus's Avatar
maximus maximus is offline Windows XP Access 2003 (version 11.0)
Wizard
 
Join Date: Aug 2009
Location: India
Posts: 802
Blog Entries: 1
maximus is on a distinguished road
Default

Answer to you second question go to Form Properties, Click on Data, Select Yes. Generally this option for a Form is No by default. Checking this option Yes will always open your form in a data entry mode i.e. a blank form.

Answer to you first question. I will assume yu alreadyhave a save button on your form. Go to the command Button Properties, Select event, Then select OnClick event and open the Vb code of the button. You will find a code very similar to one below:

Private Sub Command6_Click()
On Error GoTo Err_Command6_Click

If IsNull(Me.Inventory) Then
MsgBox "The inventory field is blank", vbInformation
DoCmd.GoToControl "Inventory"
Else

DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
End If

Exit_Command6_Click:
Exit Sub

Err_Command6_Click:
MsgBox Err.Description
Resume Exit_Command6_Click

End Sub

The part of the code in red is already there. Please type the code in black.

I have a form in which there is a field called inventory. If it is null a msgbox is displayed and the cursor moves automatically to the inventory field.

Reply With Quote
  #3  
Old 02-09-2010, 05:39 AM
RuralGuy's Avatar
RuralGuy RuralGuy is online now Windows 7 Access 2007 (version 12.0)
Administrator
 
Join Date: Mar 2007
Location: 8300' in the Colorado Rocky Mountains
Posts: 4,263
RuralGuy will become famous soon enoughRuralGuy will become famous soon enough
Default

Another method, and one I prefer, is to place all such validation code in the BeforeUpdate event of the form. That event can be cancelled if some validation fails and fires regardless of how the form is closed.
__________________
(RG for short) aka Allan Bunch MS Access MVP - WinXP Pro, Win7 - acXP, ac07
If your issue is resolved...follow this link for directions on how to use the Solved thread tool!
Teaching is not filling a bucket but lighting a fire. Borrowed quote..."Docendo discimus"
Reply With Quote
  #4  
Old 02-09-2010, 02:24 PM
cwwaicw311 cwwaicw311 is offline Windows XP Access 2003 (version 11.0)
Advanced Beginner
 
Join Date: Feb 2010
Posts: 75
cwwaicw311 is on a distinguished road
Default

thank for help guys....
Reply With Quote
  #5  
Old 02-09-2010, 07:16 PM
maximus's Avatar
maximus maximus is offline Windows XP Access 2003 (version 11.0)
Wizard
 
Join Date: Aug 2009
Location: India
Posts: 802
Blog Entries: 1
maximus is on a distinguished road
Default

Yes I agree with Rural Guy on this to coz the validation code will not help you if you have a close button activate on your form. even if validation fails the user can still close the form and the data is saved in your table. More over even if you create a close Command button on your form and place the validation code in its Onclick event and de-activate the close on button on the form the user can still close the database and the unvalidated data is saved in your table. So BeforeUpdate even is much more safe.
Reply With Quote
  #6  
Old 02-09-2010, 09:27 PM
RuralGuy's Avatar
RuralGuy RuralGuy is online now Windows 7 Access 2007 (version 12.0)
Administrator
 
Join Date: Mar 2007
Location: 8300' in the Colorado Rocky Mountains
Posts: 4,263
RuralGuy will become famous soon enoughRuralGuy will become famous soon enough
Default

Quote:
Originally Posted by cwwaicw311 View Post
thank for help guys....
Is this thread ready for you to follow the link in my sig and mark as Solved?
__________________
(RG for short) aka Allan Bunch MS Access MVP - WinXP Pro, Win7 - acXP, ac07
If your issue is resolved...follow this link for directions on how to use the Solved thread tool!
Teaching is not filling a bucket but lighting a fire. Borrowed quote..."Docendo discimus"
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
The ServerFilter of my subform is save when the form close. tazquebec Programming 2 01-29-2010 08:33 AM
Save and Go to another form - simple yes? durstlaw Forms 1 12-14-2009 09:46 PM
hide text box till you un-tick check box islandboy Access 14 09-06-2009 08:08 AM
How to display messages in the Footer Text Box after record Add, Delete, Save, etc. hello Forms 0 04-13-2009 02:02 AM
Form requesting to save changes stevo2820 Forms 0 07-30-2007 05:41 AM


All times are GMT -8. The time now is 02:40 PM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.3.2 ©2009, Crawlability, Inc.