473,326 Members | 2,081 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,326 software developers and data experts.

validating form fields problems

I am new to the VBA world. I have a form that I am trying to validate the fields on. They are either text boxes or combo boxes. I have a custom function that is called when the user clicks a command button. I cannot test any of these fields for no user input or null. None of these work:

If (Me.txtProductCode = Null) Then
' some code here
End if

or

If Len (Me.txtProductCode) = Null Then
' some code here
End if
or

If Len(Me.txtProductCode) = 0 Then
' some code here
End if

If IsNull(Me.txtProductCode) = True Then
' some code here
End if

I have tried to use the expression builder but it is very confusing for me. I'd rather do this in VB code. So, how do you check the contents of form fields in VB? Where is there some very good examples of this? Thanks

Ed Cohen | [Removed email address]
Jun 30 '06 #1
1 1710
zzqxxq
28
You just have the syntax slightly wrong:

Should be: Len(Me![txtProductCode]) You have: Len(Me.txtProductCode)
Should be: IsNull(Me![txtProductCode]) You have: IsNull(Me.txtProductCode)

You've got the parenthesis right bit the Me is followed by a ! not a period and the actual field name must be in square brackets - it should work then

If IsNull(Me![txtProductCode]) Then
' do whatever here
End if
Note you dont need the "=True" you can also say

If Not IsNull(Me![txtProductCode]) (means if its false)

Just remember you can's say "=Null" or "=Empty"

Happy coding
Jul 13 '06 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Gleep | last post by:
Hi PHP coders, I've got an issue I'm stuck with. Imagine there is a large form that has 5 columns and 20 rows. In each row there is a check box - then 4 input fields. I already have the code...
4
by: EmmettPower | last post by:
Hi, I have a form which includes a field 'number'. When 'number' is changed additional fields ('item_0', etc) are generated on the form using 'onchange'. I want to validate the form using...
3
by: Anonymous | last post by:
Hi all, I have a form people use to enter checking data. One of the fields is calculated based on finding the difference of two input fields on the form. Here are the fields: CheckAmount...
5
by: Steve | last post by:
I am currently trying to validate data in an access database. I need to verify that columns containing date information are in the format ddmmyyyy and columns containg time information are in the...
0
by: Gary Shell | last post by:
I am experiencing some strange behavior between a UserControl's validating event and a treeview control. Initially, I thought it was related to an issue in the Knowledgebase article 810852...
16
by: Al Santino | last post by:
Hi, It appears displaying a messagebox in a validating event will cancel the subsequent event. In the program below, button 2's click event doesn't fire if you open a dialog box in button 1's...
3
by: TheSteph | last post by:
Hi Experts ! I have a Winform Program in C# / .NET 2.0 I would like to ensure that a value in a TextBox is a valid Int32 when user get out of it (TextBox loose focus)
232
by: robert maas, see http://tinyurl.com/uh3t | last post by:
I'm working on examples of programming in several languages, all (except PHP) running under CGI so that I can show both the source files and the actually running of the examples online. The first...
2
by: Peted | last post by:
Hi if i derive a reference to a control on a winform (ie Control activeControl = somecontrol on the form) how can i test if that control has a validating or validated event and more importantly...
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: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
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: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
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.