If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
Validation code
Access 2003
upon saving a form (date entered on a form) I want to look at a field and confirm it is not empty (not looking for specific data). I know I need to use an if statement but not really sure of all the syntax form name = frmDonor Field Name =last_name if me.last_name = null Then MsgBox "You Must Enter a Last Name" else DoCmd.GoToRecord , , acNewRec docmd.close end if but this is not working so I have something wrong ALSO: If I want more then one field validated - but only one field check at a time How would I do that Thanks dave |
#2
|
|||
|
|||
Validation code
Dave,
Try it like this: If IsNull(Me.last_name) Then Not sure why you move to a new record and then close the form. If you're closing, just close, no need for the new record as far as I can see. If you want to check the entries in several controls, one at a time, you can use this type of structu If IsNull(Me.last_name) Then MsgBox "You Must Enter a Last Name" ElseIf IsNull(Me.other_field) Then MsgBox "You Must Enter a Other Field" Else DoCmd.Close acForm, Me.Name End If -- Steve Schapel, Microsoft Access MVP Dave wrote: Access 2003 upon saving a form (date entered on a form) I want to look at a field and confirm it is not empty (not looking for specific data). I know I need to use an if statement but not really sure of all the syntax form name = frmDonor Field Name =last_name if me.last_name = null Then MsgBox "You Must Enter a Last Name" else DoCmd.GoToRecord , , acNewRec docmd.close end if but this is not working so I have something wrong ALSO: If I want more then one field validated - but only one field check at a time How would I do that Thanks dave |
#3
|
|||
|
|||
Validation code
You would do this sort of validation in the BeforeUpdate event of the form.
The example you used would be: If Len(Me.last_name & "") = 0 Then MsgBox "You Must Enter a Last Name" Cancel = True '-- to cancel the SAVE End If Dave wrote: Access 2003 upon saving a form (date entered on a form) I want to look at a field and confirm it is not empty (not looking for specific data). I know I need to use an if statement but not really sure of all the syntax form name = frmDonor Field Name =last_name if me.last_name = null Then MsgBox "You Must Enter a Last Name" else DoCmd.GoToRecord , , acNewRec docmd.close end if but this is not working so I have something wrong ALSO: If I want more then one field validated - but only one field check at a time How would I do that Thanks dave -- RuralGuy (RG for short) aka Allan Bunch MS Access MVP - acXP WinXP Pro Please post back to this forum so all may benefit. Message posted via AccessMonster.com http://www.accessmonster.com/Uwe/For...forms/200803/1 |
#4
|
|||
|
|||
Validation code
Thank you both.
Worked like a charm dave "Dave" dave@accessdatapros wrote in message ... Access 2003 upon saving a form (date entered on a form) I want to look at a field and confirm it is not empty (not looking for specific data). I know I need to use an if statement but not really sure of all the syntax form name = frmDonor Field Name =last_name if me.last_name = null Then MsgBox "You Must Enter a Last Name" else DoCmd.GoToRecord , , acNewRec docmd.close end if but this is not working so I have something wrong ALSO: If I want more then one field validated - but only one field check at a time How would I do that Thanks dave |
#5
|
|||
|
|||
Validation code
Glad we could help.
Dave wrote: Thank you both. Worked like a charm dave Access 2003 upon saving a form (date entered on a form) [quoted text clipped - 22 lines] Thanks dave -- RuralGuy (RG for short) aka Allan Bunch MS Access MVP - acXP WinXP Pro Please post back to this forum so all may benefit. Message posted via http://www.accessmonster.com |
Thread Tools | |
Display Modes | |
|
|