![]() |
|
|
#1
|
|||
|
|||
|
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?? |
|
#2
|
||||
|
||||
|
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. |
|
#3
|
||||
|
||||
|
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" |
|
#4
|
|||
|
|||
|
thank for help guys....
|
|
#5
|
||||
|
||||
|
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.
|
|
#6
|
||||
|
||||
|
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" |
|
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|
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 |