Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

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

Posted on 2013-06-13
5
Medium Priority
?
283 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

Nothing ever in the clear!

This technical paper will help you implement VMware’s VM encryption as well as implement Veeam encryption which together will achieve the nothing ever in the clear goal. If a bad guy steals VMs, backups or traffic they get nothing.

Question has a verified solution.

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

This article describes two methods for creating a combo box that can be used to add new items to the row source -- one for simple lookup tables, and one for a more complex row source where the new item needs data for several fields.
Explore the ways to Unlock VBA Project Password Excel 2010 & 2013 documents. Go through the article and perform the steps carefully to remove VBA Excel .xls file.
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…

610 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