473,472 Members | 2,139 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

MsgBox not showing when it should

43 New Member
I have a form where the is an unbound textbox in header of the form where the user will enter how many weld are scanned before a pull test is performed. Next to it are two text boxes counting the scans, example: 1 of 5.
Once the interval of 5 is reached a msgbox appears telling the user to perform a test. Now the problem is the msgbox does not appear until the sixth record is scanned. I sure hope this makes sense,not sure how to fix this problem. Below is the code I am using:

Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_AfterInsert()
  2. If Not IsNull(Me.SN.Value) Then
  3.     LastPosSN = Me.SN.Value
  4. End If
  5. If PosPullTestCount = Me.PullTestNum.Value Then
  6.     MsgBox "Time to perform a pull-test on a scrap cell!"
  7.     PosPullTestCount = 1
  8.     Me.Text30.Value = Me.PullTestNum.Value
  9.     DoCmd.OpenForm "GeneralTabPullTest"
  10. Else
  11.     PosPullTestCount = PosPullTestCount + 1
  12.     Me.Text30.Value = Me.PullTestNum.Value
  13. End If
  14. End Sub
Thanks
Mar 20 '13 #1
3 4518
zmbd
5,501 Recognized Expert Moderator Expert
Please start here:
>> Before Posting (VBA or SQL) Code.

What you'll find, is that your code is adding the final count; however, you don't test value again until the next click event.
Mar 20 '13 #2
tmdrake
43 New Member
Thanks, so how do I fix the code to tell it to test value on final count?
Mar 20 '13 #3
zmbd
5,501 Recognized Expert Moderator Expert
tmdrake:
I don't mean to sound offish/condescending etc... really I don't; however, you really should be able to look at your code and be able to fix that issue - it is that fundamental.

However:
Put a "Stop" command just before line 2 in your posted code.
Now start the event, the vba editor will start, you should arrange the windows so that you can get at the form and the vba editor, [F8] to step thru the code.
Click and Step thru the code until you get to that 5th time... take note of your logic branch -
When did you increment the value?
When did you test it?

Seriously, this will like the "I-could've-had-a-V8" commercials where the actor hits their head kind of momement.

Goto the insights list: Microsoft Access / VBA Insights Sitemap
Read thru articles: 136,135,133,132,131,130,129,128,127,126
Mar 20 '13 #4

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

Similar topics

16
by: garyolsen | last post by:
For a class, MyClass, there are two ways to instantiate an object: 1. MyClass *MC = new MyClass(); 2. MyClass MC; In general, when should you have to use 1 and when 2? What're...
6
by: Terry Bell | last post by:
We've had a very large A97 app running fine for the last seven years. I've just converted to SQL Server backend, which is being tested, but meanwhile the JET based version, running under terminal...
1
by: Agnes | last post by:
In my one form, the user need to search many field, e.g customer name, country name, currency.. etc They are using the same conMaster , So, when Should I closed the connection ?? 1st) if the user...
2
by: My SQL | last post by:
Hi I just have one server that runs Apache, MySQL, PHP. It handles requests fine and never had problems. When should I think about a small step into scaling? By maybe having an independent MySQL...
8
by: FAQ server | last post by:
----------------------------------------------------------------------- FAQ Topic - When should I use eval? ----------------------------------------------------------------------- The ` eval() `...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.