Solved

Best place to place code to check if a certain cell isNull or Equals Zero

Posted on 2013-06-13
5
281 Views
Last Modified: 2013-06-18
Drawing a blank on the best place to but the code to check the value of certain field.

the field is on 1 of many subforms of a main form (tabs).  I have tried it on Load of subform, ONcurrent etc.  the code does not seem to check the value of the field.  any ideas.

Thanks,

K

 If IsNull(Forms![frmProformaInv]![chdProformaWO].Form![PricePerUnit1]) Or _
     Forms![frmProformaInv]![chdProformaWO].Form![PricePerUnit1] = 0 Then
          Call _
              MsgBox("The Unit Price currently is missing or contains a Zero value.  Please review and enter the correct value.", _
              vbExclamation, "Unit Price Is Not Validate")
    Me.PricePerUnit.SetFocus
    Me.PricePerUnit.Enabled = True
 End If

Open in new window

0
Comment
Question by:Karen Schaefer
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 4

Expert Comment

by:BAKADY
ID: 39245999
where is this code in your form or in a simple modul?

if the code is in your form, you should have a object name for your formular's objects, ... this mean, if you create a object names combo1 you can access to his value like this:

Dim strSomeString as String

strSomeString = combo1.text  ' or
strSomeString = me.combo1.text 'or
strSomeString = frmMyForm.combo1.text

in your case, i'm a little bit confused

Forms![frmProformaInv]![chdProformaWO].Form![PricePerUnit1]

frmProformaInv is your Form
chdProformaWO should be your object
PricePerUnit1 or it's this one

anyway
frmProformaInv.chdProformaWO.Value 'or .Text or .ListIndex or the property which you want to get the value

i'm glad to help you, if this doesn't work, please post more information about.
0
 

Author Comment

by:Karen Schaefer
ID: 39246009
I mean should if be in after update of the sub form, the mainform, etc.  or onFocus of subform

I need to check on focus of the subform to check if the value is null and also on exit of the subform or change of record on the subform for the null value.

Where should I place the code?

K
0
 
LVL 4

Expert Comment

by:BAKADY
ID: 39246079
has "PricePerUnit1" a datasource? i mean a table's field...

if a really unterstand your problem, your have a field - maybe numeric - names PricePerUnit1, this couldn't be NULL. right?

in this case nowhere in vba, into your table. In access under the field's properties you can define first a "Validation Rule" and second set a "validation message", this one will automatically displayed if the rull doesn't match, you don't need to write it in vba.

Validation Rule: > 0 and Is Not Null
Validation Message: The Unit Price currently is missing or contains a Zero value.  Please review and enter the correct value.
0
 

Accepted Solution

by:
Karen Schaefer earned 0 total points
ID: 39246251
yes it is numeric, however that is not the issue, I need the system to notify the user that the field for the active record contains a zero value or is null.

I added the code to the OnCurrent of the subform and this seems to have resolved the issue.

Thanks for your input.
0
 

Author Closing Comment

by:Karen Schaefer
ID: 39255637
Solve the issue on my own.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
The Windows Phone Theme Colours is a tight, powerful, and well balanced palette. This tiny Access application makes it a snap to select and pick a value. And it doubles as an intro to implementing WithEvents, one of Access' hidden gems.
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

691 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question