Number Error Problem

First of all thanks for reading my post.
I have 4 number fields in my table. The default is set to nothing, not 0.
In my form when I click on numbers 1-3 I have no problem. I did a msgbox on
number 3 and 4. Number  3 field shows nothing and no error. Number 4 field
shows a 0 and gives me a null error

I have all the fields dim as integer

Here is my code for number 4 field: 
Private Sub Unit4_GotFocus()
MsgBox u4
10    u4 = Unit4
End Sub

Am I doing something wrong? I have fields set up the same way as above and I
don't have a problem.

What I'm trying to do is to compare u4 with the new information in field 4.
Private Sub Unit4_BeforeUpdate(Cancel As Integer)
20    If Unit4 < u4 Then
30    Tot = Tot - Unit4
40    Else
50    Tot = Tot + Unit4
60    End If
End Sub

Again, thanks for your help.

-- 
Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/Forums.aspx/access-formscoding/201006/1

0
Afrosheen
6/4/2010 1:50:06 PM
access.formscoding 7493 articles. 0 followers. Follow

3 Replies
1054 Views

Similar Articles

[PageSpeed] 23

On Fri, 04 Jun 2010 13:50:06 GMT, "Afrosheen via AccessMonster.com"
<u46942@uwe> wrote:

If u4 is null at the time you run the "Msgbox u4" line, you will get
this error. Set a breakpoint on this line, run the code again, and
inspect the value.

One way this often happens is if "Option Explicit" is not set at the
top of every module. Set this to be the default in Tools > Options as
well.

Another way is if you dim variables incorrectly:
Dim u1, u2, u3, u4 As Integer
Debug.Print VarType(u1), VarType(u2), VarType(u3), VarType(u4)
results in:
 0             0             0             2 
Look up VarType in the help file.
Resolve to declare one variable per line.

-Tom.
Microsoft Access MVP



>First of all thanks for reading my post.
>I have 4 number fields in my table. The default is set to nothing, not 0.
>In my form when I click on numbers 1-3 I have no problem. I did a msgbox on
>number 3 and 4. Number  3 field shows nothing and no error. Number 4 field
>shows a 0 and gives me a null error
>
>I have all the fields dim as integer
>
>Here is my code for number 4 field: 
>Private Sub Unit4_GotFocus()
>MsgBox u4
>10    u4 = Unit4
>End Sub
>
>Am I doing something wrong? I have fields set up the same way as above and I
>don't have a problem.
>
>What I'm trying to do is to compare u4 with the new information in field 4.
>Private Sub Unit4_BeforeUpdate(Cancel As Integer)
>20    If Unit4 < u4 Then
>30    Tot = Tot - Unit4
>40    Else
>50    Tot = Tot + Unit4
>60    End If
>End Sub
>
>Again, thanks for your help.
0
Tom
6/4/2010 2:08:04 PM
Thanks for getting back so fast.
This is what I did. When I changed the dim to all one line then ran the debug.
print. The answers I got were all 2.

Tom van Stiphout wrote:
>If u4 is null at the time you run the "Msgbox u4" line, you will get
>this error. Set a breakpoint on this line, run the code again, and
>inspect the value.
>
>One way this often happens is if "Option Explicit" is not set at the
>top of every module. Set this to be the default in Tools > Options as
>well.
>
>Another way is if you dim variables incorrectly:
>Dim u1, u2, u3, u4 As Integer
>Debug.Print VarType(u1), VarType(u2), VarType(u3), VarType(u4)
>results in:
> 0             0             0             2 
>Look up VarType in the help file.
>Resolve to declare one variable per line.
>
>-Tom.
>Microsoft Access MVP
>
>>First of all thanks for reading my post.
>>I have 4 number fields in my table. The default is set to nothing, not 0.
>[quoted text clipped - 23 lines]
>>
>>Again, thanks for your help.

-- 
Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/Forums.aspx/access-formscoding/201006/1

0
Afrosheen
6/4/2010 2:56:48 PM
Hi Tom,
I couldn't get it so I cheated. I put a 5 Dim and then the 4 fields worked.
The 5Dim is just a dummy Dim and don't need it.

It's probably not the right way to do it.

Thanks for the help.


Afrosheen wrote:
>Thanks for getting back so fast.
>This is what I did. When I changed the dim to all one line then ran the debug.
>print. The answers I got were all 2.
>
>>If u4 is null at the time you run the "Msgbox u4" line, you will get
>>this error. Set a breakpoint on this line, run the code again, and
>[quoted text clipped - 20 lines]
>>>
>>>Again, thanks for your help.

-- 
Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/Forums.aspx/access-formscoding/201006/1

0
Afrosheen
6/4/2010 8:50:49 PM
Reply:

Similar Artilces:

Microsoft Outlook has encountered a problem and needs to close #2
After installing Microsoft service pack (sp2) and while opening Outlooks 2000 (Office 2000);I recieved this error message, "Microsoft Outlook has encountered a problem and needs to close." Can anyone offer a suggestion to fix this problem? >-----Original Message----- >After installing Microsoft service pack (sp2) and while >opening Outlooks 2000 (Office 2000);I recieved this error >message, "Microsoft Outlook has encountered a problem and >needs to close." > >Can anyone offer a suggestion to fix this problem? >. > i have the same pro...

Numbering
Can I enter numbers in a cross functional flowchart? On Mon, 24 Aug 2009 12:07:02 -0700, carosaam <carosaam@discussions.microsoft.com> wrote: >Can I enter numbers in a cross functional flowchart? Yes. Do you mean for the process names or function names? Yes. -- Regards, Paul Herber, Sandrila Ltd. Electronics for Visio http://www.electronics.sandrila.co.uk/ Electrical for Visio http://www.electrical.sandrila.co.uk/ Electronics Packages for Visio http://www.electronics-packages.sandrila.co.uk/ ...

CRM 4
We had a CRM 4 setup which was working successfully: - Server 1 is a Windows 2003 Server with CRM Server installed - Server 2 is a Windows 2003 Server with SQL 2005, Reporting Services with CRM Data connector installed The SQL 2005 server was upgraded to SQL 2008 Enterprise. After the installation and rebooting, the CRM Server was working apart from Reports. REPORT ERROR MESSAGES ====================== When a report is run from a CLIENT machine, the following error appears - "The request failed with HTTP status 401: Unauthorized." [WebException: The request failed with HTTP status...

Sending and Receiving Error?
Ever since I upgraded from Outlook 2000 to Office XP (Outlook 2002, SP-2 on Win 2K), I have been getting lots of errors with one of the two mail servers I use (Comcast). The message in the Details box is always some variation of this: ---- Task '2 Comcast - Sending and Receiving' reported error (0x800CCC0F) : 'The connection to the server was interrupted. If this problem continues, contact your server administrator or Internet service provider (ISP). The server responded: ??K' ---- The "server responded" code is sometimes a bit different, but generally looks ...

Outputting a CString to File Problem
Hello, Currently I am using Visual C++ 2005 Pro, with an MFC application. However, when I attempt to output a CString to a file via ofstream, the resulting output is a hex value, not the text in the CString I intended. Does anybody have any ideas why this would happen? Here is the code snippet in question: CString sPathToSettings = GetWorkingDirectory(); sPathToSettings += "settings.ini"; ofstream OutFile(sPathToSettings); OutFile << sPathToSolution; OutFile.close(); BTW: The sPathToSettings string points to a valid path, as it does create a file successfully. ...

negative number to positive number
How can I change a negative number to positive number Multiply by -1 or use the ABS() function. -- Cordially, Chip Pearson Microsoft MVP - Excel Pearson Software Consulting, LLC www.cpearson.com "fgiord" <fgiord@discussions.microsoft.com> wrote in message news:62C2A6DA-7AC2-4379-AEFC-B3D6F3698E58@microsoft.com... > How can I change a negative number to positive number =ABS(##) or mult it by -1 -- Regards Rob "fgiord" <fgiord@discussions.microsoft.com> wrote in message news:62C2A6DA-7AC2-4379-AEFC-B3D6F3698E58@microsoft.com... > How can I chan...

Error code 3021 in the QSImport Utility Log
We are trying to import Inventory items and about 10% of the records show up in the error log with an error code. We've examined the records, in our Excel file and the Tab delimited conversion file, and they look OK. An example error code looks like [00110 00003021] ...

How do I expand the number of characters in Access comment box?
I am using Access 2007 and want to be able to include more than 250 characters in a "Comment" box. Hi, You could try changing your table's field type to Memo. Assuming that your are talking about a field in a table, that maybe shows on a form. If that is not the case, please describe precisely what comment box your are attempting to use. Clifford Bass Pearlene wrote: >I am using Access 2007 and want to be able to include more than 250 >characters in a "Comment" box. -- Message posted via http://www.accessmonster.com ...

1-52 pages, 8,000 employee numbers
Dear Excel, I have the ultimate challenge: to do job books for 8,000 employees. The form is completed, but the request is to make booklets of 52 pages for each employee. Each page of the booklet must also have each employee's number on it (0001 to 8000). Each page o fthe booklet must be numbered with the week number from 01 to 52. Therefore I need to auto generate 416,000 pages. Ridiculous I know but nobody listens to us! How can I export the above scenario to PDF from Excel? Thanks On Apr 19, 2:17=A0pm, gatecrasherg13 gatecrasherg13 <gatecrasher...@gmail.com> wr...

Sharing workbook error message
After sharing a workbook, when I go to save it I get this message, "This workbook is no longer shared'. Why? ...

Hide page numbers for mutliple discontiquous levels
Hi: I need to hide the page numbers for levels 1 and 7 in my TOC. I used the \n switch to hide level 1, but cannot find a way to specify multiple ranges for this switch. Is there a way to do this? I am using Word 2003. Phil You have to use a trick. See the "Omitting page numbers for noncontiguous levels" section of http://sbarnhill.mvps.org/WordFAQs/TOCTips.htm#OmitPageNumbers -- Suzanne S. Barnhill Microsoft MVP (Word) Words into Type Fairhope, Alabama USA http://word.mvps.org "Phillip Llacuna" <phillip.v.llacuna@lmco.com> wrote in me...

Error Message #7
When attempting to start money 2003 receive the following error message."This application has asked the Runtime to terminate in an unusual way. Please contact the support team for more information." I have uninstalled and reinstalled the program. Same error message. a fix that is often the first thing that any support person will have you try is to go to "RUN" and enter msmoney.exe -s this is some sort of database repair startup of Money. give it a try. >-----Original Message----- >When attempting to start money 2003 receive the following >error message....

Windows 7 AD problem
Frustrating issue here: I have a windows server 2003 AD infrastructure. I Windows 7 as my company computers. I have 1 user (user A) that, when logged into the network, loses control of his screen when user B starts typing. I have made sure that IPs are not conflicting. I have created different accounts for both of them but still keep having the same bad luck. It is causing user A to not be able to work because whenever user B is typing an e-mail it literally takes control of user A's screen and starts typing into whatever program he has open. I have never seen nor ...

Sequential numbering in Number field
When I am entering transactions manually, I will put "Debit" or "VISA" to indicate how the withdrawl was made. When I download my account information, Money05 overwrites this with a sequential number. I have to go into the entry a second time to redo my change. Does anyone know how to turn this "feature" off? I want my values used - sequential numbering does not help me in the slightest. This is not a "feature" you can turn off. It's a reflection of the basic premise of downloaded transaction data. The presumption with downloading data...

problem receiving mails for remote clients.....
hai all, we are using exchange 5.5 and we have 6 branches they all connect to exchange server remotely using outlook 2000 with pop3 ip address before everything ok from two days to what it is showing for clients when they press send and receive downloading mail from '202.125.85.187'........ Receiving message 1 of 9 Some errors occurred while processing the requested tasks. Please review the list of errors below for more details. Receiveing mail on account 202.125.85.187 Failed then in outlook...

General Number Format Changed
Excel 2003 on XP I have a collegue who's Excel setting for General number format displays as 0.1 instead of 1 in the sample box. ie if you type in "1" you get "0.1", if you type in ".1" (as in 0.1) you get "1". Where in the settings can this General format be returned to standard? Many thanks DeanH Sorry that should have been: ie if you type in "1" you get "0.1", if you type in "1." (as in 1.0) you get "1". "DeanH" wrote: > Excel 2003 on XP > I have a collegue who's Excel setting for G...

Personal Macro File Closing Error
When I close my Personal macro file, I get the error message, "This workbook is currently reference by another workbook and cannot be closed". When I hit OK or close the dialog box, Excel will close. It has no impact on the file itself but is annoying. I'd like to correct this but nothing I've seen addresses this issue. Since Excel 97 a workbook that is referenced (under Tools, References in the Visual Basic Editor) by another open workbook cannot be closed. If the reference is unintentional you should check each open workbook for the reference, remove it and save ...

Number of Cells in a column
Hi, I want to add this formula in my ESS. COUNTIF(sheet1!S2:S43,"*Yes*") to find out the number of value containing "YES". My concern is I don't have fixed count from S2 to S43. It could be something else. What can I do to have this code reusable? I thought something like COUNTIF(Sheet!S2:Count($S2),"*Yes*") \But it doesnt work Thanks for your help Jack Try this if there is nothing else in that column:- =COUNTIF(sheet1!S:S,"*Yes*") -- Regards Ken....................... Microsoft MVP - Excel Sys Spec - ...

How to define cells so that only numbers can be filled?
Hi, How could I format cells in excel so that only numbers can be filled The input should be integer e.g. between 0...99 and cells shoud no accept any other marks, such as space, letters... simply nothing els but integers. Thanks -- Message posted from http://www.ExcelForum.com Hi Juha! Try: Data > Validation You'll find it pretty intuitive and very flexible as to what you can do as far a restricting input to a cell. -- Regards Norman Harker MVP (Excel) Sydney, Australia njharker@optusnet.com.au Excel and Word Function Lists (Classifications, Syntax and Arguments) available fre...

Problems migrating PST files from Outlook 2000 to 2003
One of the users I support bought a new laptop with Office2003 on it. Her old machine had all the mail in 2 PST files (outlook.pst and archive.pst.) After setting up her mail (Internet mail for her home office,) I copied over the pst files. I closed outlook and set up the personal folders from the mail icon in the control panel. I selected the folder type as outlook 97~2002. When I open outlook, I can see the folders within the personal folders but not the mail. I tried the inbox repair tool but it didn't help. This is the first time I've worked with Outlook2003 and frankly ...

Formula error #2
I am trying to create a simple formula to grab the text from a cell in another worksheet (same workbook). Instead of getting the text, the following is displayed (which is the text of my formula, not the text in the cell it should be reading): ='amen shell'!c1 What am I doing wrong?? Thanks! Your cell was probably formatted as Text when you entered your formula. Change the format to General, click in the cell to edit, then hit Enter. In article <43B3041F-CBAE-408F-AE25-FDD8323FE625@microsoft.com>, Ashley <anonymous@discussions.microsoft.com> wrote: > I am trying t...

Numbering, revisited
While there are already a lot of posts about numbering, I haven't been able to find the solutions for my specific quandry... [BTW, I'm posting this under "General" even though ultimately I'd like to make macros to support the answer -- since a manual solution needs to be the first step! :) ] Background: My workgroup is preparing to migrate to Word 2007 very soon. We create/maintain hundreds of large procedure manuals, each containing multiple chapters (sometimes up to 40-50 per manual). Each chapter consists of steps, using multi-level numbered lists...

Limit number of characters in a cell
Hi, Is there a way to limit the number of characters that a user can key into a cell. I want to get a list of names and addresses imputted by user, but I don't want them to be more than 35 characters. Thanks for the help Dr. Senji Take a look at Data|Validation. You can have excel yell at the user when they hit enter after typing in a too-long string. Dr Senji wrote: > > Hi, > > Is there a way to limit the number of characters that a user can key into a > cell. > > I want to get a list of names and addresses imputted by user, but I don't > want the...

transaction number in PC Charge
Is there any way to manage the fields that should go to PC Charge while tendering credit cards in RMS. The problem is that transaction number ( called Ticket in PC Charge) doesn't appear in PC Charge and that cost as extra money. Regards, Ewa ...

Windows Scheduler Error
When I run the scheduler, I get this message: "The Task Image is corrupt or has been tampered with. User.Feed.Synchronization-{08D8EE38-23BB-4C70-8FAD-84B0186399CA}" Any suggestions on resolving this? Thanks! ...