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 / March 2008

Tip: Looking for answers? Try searching our database.

set text box to blank(Null)

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
NNlogistics - 13 Mar 2008 15:25 GMT
Sorry for this question.  It seems to be well covered but I quess I'm thicker
than most.  I am trying to set a text box to nothing - Blank - Null.  I
thought I understand the difference but here goes.

My code looks like this
If Left(Me.txtProductCode, 1) <> 1 Then
   MsgBox ("Service Charge Codes always start with '1'")
   Cancel = True
   Me.txtProductCode.Value = Null
                                        =""

The underlying field is a text field
   Exit Sub
End If
I get a run Time error 2115

Ive tried = ""
tried  Me.txtProductCode = null

Signature

Thanks for any assistance

Allen Browne - 13 Mar 2008 15:58 GMT
If the field's Required field is set to Yes, then the attempt to set the
field to null will fail.

Instead, undo the field:

   Me.txtProductCode.Undo

Signature

Allen Browne - Microsoft MVP.  Perth, Western Australia
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

> Sorry for this question.  It seems to be well covered but I quess I'm
> thicker
[quoted text clipped - 15 lines]
> Ive tried = ""
> tried  Me.txtProductCode = null
Douglas J. Steele - 13 Mar 2008 16:05 GMT
Take a look at the error message associated with that error:

"The macro or function set to the BeforeUpdate or ValidationRule property
for this field is preventing @ from saving the data in the field.@* If this
is a macro, open the macro in the Macro window and remove the action that
forces a save (for example, GoToControl).
* If the macro includes a SetValue action, set the macro to the AfterUpdate
property of the control instead.
* If this is a function, redefine the function in the Module window."

(If your error handling isn't showing the error's Description property, you
can go to the immediate window, type

?AccessError(2115)

and hit Enter)

In other words, it sounds as though you're trying to run that code in the
BeforeUpdate event of the txtProductCode control. You cannot change a
control's value in its BeforeUpdate event. Either leave the value there,
making the user rekey it, or put your check into the Form's BeforeUpdate
event.

Signature

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

> Sorry for this question.  It seems to be well covered but I quess I'm
> thicker
[quoted text clipped - 15 lines]
> Ive tried = ""
> tried  Me.txtProductCode = null
NNlogistics - 13 Mar 2008 17:01 GMT
Thank you Allen and Doug - Very Helpful
Signature

Thanks for any assistance

> Sorry for this question.  It seems to be well covered but I quess I'm thicker
> than most.  I am trying to set a text box to nothing - Blank - Null.  I
[quoted text clipped - 14 lines]
> Ive tried = ""
> tried  Me.txtProductCode = null
 
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.