Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Forms Programming / May 2005

Tip: Looking for answers? Try searching our database.

Before Update Code

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Karen - 13 May 2005 14:52 GMT
I put the following code into my BeforeUpdate event and I'm getting the
following error message:

Run Time error '2465'
Microsoft Office Access can't find the field 'txtThis' referred to in your
expression.

Private Sub Form_BeforeUpdate(Cancel as Integer)
If Me!txtThis & Me!txtThat & Me!txtTheOther & Me!txtWho _
 & Me!txtWhat & Me!txtIDontKnow = "" Then
  Cancel = True
  MsgBox "You must fill out every field in this form", vbOKOnly
End If
End Sub

HELP!
Rick Brandt - 13 May 2005 15:17 GMT
> I put the following code into my BeforeUpdate event and I'm getting
> the following error message:
[quoted text clipped - 12 lines]
>
> HELP!

The error pretty much explains itself.  If you do not have either a field or a
control on the form with that exact name then you will get that message.  Are
you sure you spelled it correctly.

By the way your code will NOT do what you want it to.  You will only get the
MsgBox if ALL fields were left empty (I assume you want it if even one field was
left empty).  Plus testing for "" will not catch Nulls which is more likely to
be the case.

You need something like...

If Len(Nz(Me!txtThis,"")) = 0 _
Or  Len(Nz(Me!txtThat,"")) = 0 _
Or ...

Signature

I don't check the Email account attached
to this message.     Send instead to...
RBrandt    at       Hunter      dot      com

Karen - 13 May 2005 20:01 GMT
Thank you for your help Rick - I'm still having problems. I'm sure it's
something I'm doing wrong. Would you be so kind to give me the code exactly
how it should be so I can copy and paste it into the BeforeUpdate event? I
hope this isn't asking too much.  Thank you

> > I put the following code into my BeforeUpdate event and I'm getting
> > the following error message:
[quoted text clipped - 27 lines]
> Or  Len(Nz(Me!txtThat,"")) = 0 _
> Or ...
Rick Brandt - 13 May 2005 21:00 GMT
> Thank you for your help Rick - I'm still having problems. I'm sure
> it's something I'm doing wrong. Would you be so kind to give me the
> code exactly how it should be so I can copy and paste it into the
> BeforeUpdate event? I hope this isn't asking too much.  Thank you

Private Sub Form_BeforeUpdate(Cancel as Integer)

If Len(Nz(Me!txtThis, "")) = 0 _
Or  Len(Nz(Me!txtThat, "") = 0 _
Or Len(Nz(Me!txtTheOther, "")) = 0 _
Or Len(Nz(Me!txtWho, "")) = 0 _
Or Len(Nz(Me!txtWhat, "")) = 0 _
Or Len(Nz(Me!txtIDontKnow, "")) = 0 Then
   MsgBox "You must fill out every field in this form", vbOKOnly
   Cancel = True
End If

End Sub

Signature

I don't check the Email account attached
to this message.     Send instead to...
RBrandt    at       Hunter      dot      com

Karen - 16 May 2005 17:19 GMT
Thanks for your help - Although, when I paste the code into my BeforeUpdate
event, 6 lines of code changes to red.  Starting with "If Len(Nz(Me!txtThis,
"")) = 0 _"

Why is this happening?
Thank you, Karen

> > Thank you for your help Rick - I'm still having problems. I'm sure
> > it's something I'm doing wrong. Would you be so kind to give me the
[quoted text clipped - 14 lines]
>
> End Sub
Douglas J. Steele - 16 May 2005 22:16 GMT
Do you have a space in front of the underline character?

Signature

Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)

> Thanks for your help - Although, when I paste the code into my
> BeforeUpdate
[quoted text clipped - 23 lines]
>>
>> End Sub
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.