Before Update Cancel = True

W

Warman

I know this is dumb but I am stuck:

My form has Before Update: Cancel = True.

No one can add a record which is want I want. When all information is
entered and verified, I have several command buttons that can be "clicked"
for several different options. My question, how do I now add the record to
the table. With Cancel = True, nothing happens.

Sorry, not a programmer.
 
S

Stefan Hoffmann

hi,
No one can add a record which is want I want. When all information is
entered and verified, I have several command buttons that can be "clicked"
for several different options. My question, how do I now add the record to
the table. With Cancel = True, nothing happens.
This event is the right place for executing the verification. So instead
of hard-coding the Cancel value you need to evaluate it. E.g.

Private Sub Form_BeforeUpdate(Cancel As Integer)

Cancel = Len(Trim(Nz(txtFirstName.Value + txtLastName.Value, "")) > 0)

End Sub

for testing if first name and last name are not null or empty.
Sorry, not a programmer.
You need to learn a little bit at this point:

http://msdn.microsoft.com/en-us/library/aa211264(office.11).aspx

mfG
--> stefan <--
 
J

Jack Leach

You need some sort of If/Then (or other conditional statement) to decide
whether or not to run the Cancel = True statement.

Ex.

Private Sub Form_BeforeUpdate(Cancel As Integer)
If IsNull(Me.Textboxname) Then
MsgBox "Enter a value so you can save"
Cancel = True
End If
End Sub


so with the above, if they haven't entered anything into a control called
textboxname, the record will not save, otherwise it will.


hth

--
Jack Leach
www.tristatemachine.com

"I haven''t failed, I''ve found ten thousand ways that don''t work."
-Thomas Edison (1847-1931)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top