473,322 Members | 1,398 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

how to create Is Not Null for textbox

I have a form linked to a Table.
In the form, I have some textboxes, some checkboxes, and a AddRecord
command button.
I set the validation rule of the txtEmpNo textbox to Is Not Null, I
set the validation text to 'required field'. I entered in the
AddRecord.Mousedown section:
If Me.txtEmpNo.text = "" Then
MsgBox("Required Field")
Me.txtEmpNo.SetFocus
End If

No error message pops up and the record still gets entered in the
Table. How do I get an error message to pop up and not insert the
record.
signed A confused beginner programmer

Mar 16 '06 #1
4 8202
On Thu, 16 Mar 2006 00:11:09 -0800, Stephen D Cook <st******@comcast.net> wrote:
I have a form linked to a Table.
In the form, I have some textboxes, some checkboxes, and a AddRecord
command button.
I set the validation rule of the txtEmpNo textbox to Is Not Null, I
set the validation text to 'required field'. I entered in the
AddRecord.Mousedown section:
If Me.txtEmpNo.text = "" Then
MsgBox("Required Field")
Me.txtEmpNo.SetFocus
End If

No error message pops up and the record still gets entered in the
Table. How do I get an error message to pop up and not insert the
record.
signed A confused beginner programmer


You are testing for 2 different conditions.
You have a validation rule of Is Not Null but you code is testing for a zero
length string ("").

A ZLS is not the same as Null. Although they both appear as a blank field in a
table, they are completely different animals.

Use If IsNull(Me.txtEmpNo) Then

or to test for both conditions at once use -

If Len(Me.txtEmpNo & vbNullString)=0 Then
Wayne Gillespie
Gosford NSW Australia
Mar 16 '06 #2
> Use If IsNull(Me.txtEmpNo) Then

or to test for both conditions at once use -

If Len(Me.txtEmpNo & vbNullString)=0 Then


You can also use the following instruction:

If Nz(strMyVar, "") = "" Then

--
PBsoft di Gabriele Bertolucci
www.pbsoft.it
skype: pbsoftsolution
Mar 16 '06 #3
I tried each of the suggestions and in each case, no warning, and the
data still goes into the Table. Any other ideas?

I found if I keep the validation rule as Is Not Null and a validation
text to let the user know whats wrong, then make the cmdAddRecord
button not visible til data is entered into the txtEmpNo that it
works. But this seems to be a strange way to do it.

Mar 16 '06 #4
Instead of using the table field 'Validation Rules' stuff, on the form
in the On_Click event of the 'AddRecord' button add the code that Wayne
suggested " If Len(Me.txtEmpNo & vbNullString)=0 Then "

bobh.

Mar 16 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Bil Muh | last post by:
Esteemede Developers, I would like to Thank All of You in advance for your sincere guidances. I am developing a software using Visual C++ .NET Standard Edition with Windows Form (.NET)...
6
by: SamIAm | last post by:
Hi am creating a email application that needs to mail out a very large amount of emails. I have created a multithreaded c# application that using message queuing. I have created a threadpool of 5...
10
by: Sandy | last post by:
I have a bunch of textboxes that it is all right for them to be null How do I program that? I keep getting an error that says Null is no longer supported Sandy
3
by: TheSebaster | last post by:
I would like to create an instance of System.Windows.Form.TextBox but I just have the name of the objec in a string like that: string strType = "System.Windows.Form.TextBox"; I tryed myOgject...
0
by: cscan | last post by:
Hi all, I write 2 controls. (Acutally I simplifed my project here) MyTextBox and MyPanel. MyPanel contains a property which is a collection of MyTextBox. public partial class MyPanel :...
3
by: suek | last post by:
I have a table with over 4000 records to search upon, and the users don't like a combo box. So what I have been trying to do for the last twelve hours is do some code to get a text box to search. ...
1
by: MaryamSh | last post by:
Hi, I am creating a Dynamic Search in my application. I create a user control and in Page_load event I create a dynamic dropdownlist and 2 dynamic button (Add,Remove) By pressing Add button...
0
by: MaryamSh | last post by:
Create Dynamic Dropdownlist Controls and related event -------------------------------------------------------------------------------- Hi, I am creating a Dynamic Search in my application. I...
4
by: justice750 | last post by:
Hi All, I am using a FormView control. The allows me to update records in the database. However, when a database field is null I can not update the field on the form. It works fine when the field...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.