473,498 Members | 1,700 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Msg Box pop up based on certain criteria

4 New Member
Access 2000 Database using VBA. Windows XP SP2.
English.

I have a form which contains some bits of information. Item Number, Purchase Cost, Standard Cost, and a Purchase Order Number.

In the event that there is a Purchase Cost entered which is > then 0 but the Standard = 0, I would like a popup to display which halts the process until a Standard gets entered.

I am not a coder but I can usually cobble the code together through some trial and error. This one has me stuck but I feel it is something simple.

For the time being, while testing this I have a button which executes the code when clicked. Right now nothing happens when it clicks despite the error conditions being present. No errors, which tells me that something is incomplete.

Here is the code:
Expand|Select|Wrap|Line Numbers
  1. Private Sub Command14_Click()
  2. Dim item_no As String
  3. Dim loc As String
  4. Dim std_cost As Double
  5. Dim sql_s As String
  6. Dim db As dao.Database
  7. Dim rst As dao.Recordset
  8. Dim sqlstr As String
  9. Dim ord_no As String
  10. Dim exp_unit_cost As Double
  11. Dim right_ord_no As String
  12. Dim stk_loc As String
  13. Dim right_val As Double
  14. Dim exp_val As Double
  15. Dim std_val As Double
  16.  
  17. Set db = CurrentDb()
  18.  
  19. sqlstr = "SELECT item_no, loc, std_cost FROM [dbo_iminvloc_sql] WHERE item_no = '" & Me![item_no] & "'"
  20.  
  21. Set rst = db.OpenRecordset(sqlstr)
  22.  
  23. ord_no = Me![ord_no]
  24. right_ord_no = Right(Me![ord_no], 2)
  25. exp_unit_cost = Me![exp_unit_cost]
  26. std_cost = rst![std_cost]
  27.  
  28.  
  29. If right_ord_no = "00" Then right_val = 1
  30.  
  31. If expected_unit_cost > 0 Then exp_val = 1
  32.  
  33. If std_cost = 0 Then std_val = 1
  34.  
  35. If right_val + exp_val + std_val = 3 Then
  36. MsgBox "No Standard Exists for this item. Please have a standard entered." & vbNewLine & vbNewLine & _
  37.         "Quitting...", vbCritical, "E-Mail Merger"
  38.  
  39.  
  40.  
  41. End If
  42. End Sub
  43.  
Nov 8 '07 #1
1 1360
MMcCarthy
14,534 Recognized Expert Moderator MVP
Try this instead ...

Expand|Select|Wrap|Line Numbers
  1. Private Sub Command14_Click()
  2. Dim db As DAO.Database
  3. Dim rst As DAO.Recordset
  4. Dim sqlstr As String
  5. Dim right_val As Integer
  6. Dim exp_val As Integer
  7. Dim std_val As Integer
  8.  
  9.     Set db = CurrentDb()
  10.  
  11.     sqlstr = "SELECT item_no, loc, std_cost FROM [dbo_iminvloc_sql] WHERE item_no = '" & Me![item_no] & "'"
  12.  
  13.     Set rst = db.OpenRecordset(sqlstr)
  14.  
  15.     rst.MoveFirst
  16.     If Right(Me![ord_no], 2) = "00" Then right_val = 1
  17.     If Me![exp_unit_cost] > 0 Then exp_val = 1
  18.     If rst![std_cost] = 0 Then std_val = 1
  19.     If right_val + exp_val + std_val = 3 Then
  20.         MsgBox "No Standard Exists for this item. Please have a standard entered." & vbNewLine & vbNewLine & _
  21.         "Quitting...", vbCritical, "E-Mail Merger"
  22.     End If
  23.  
  24.     rst.Close
  25.     Set rst = Nothing
  26.  
  27. End Sub
  28.  
Nov 8 '07 #2

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

Similar topics

0
1475
by: SC | last post by:
Hi, I intend to build a system where events will be triggered when certain criteria are satisfied. The criteria are based on the calculations on a large set of data stream that gets updated once...
4
2074
by: No Spam | last post by:
Dear Access 2000 users, I have a crosstab query that puts together certain information perfectly. It has a criteria that is based on a form that limits how many columns are returned based on...
1
4153
by: Matthew | last post by:
Hey, I have built a form that has certain combo and text boxes on it, which a user specifies his criteria and then clicks on a search button to run a query based on that criteria. To build to...
8
13267
by: Brian L. Troutwine | last post by:
I've got a problem that I can't seem to get my head around and hoped somebody might help me out a bit: I've got a dictionary, A, that is arbitarily large and may contains ints, None and more...
27
10169
by: 3acks | last post by:
I've read a lot of articles and forums trying to figure this one and have yet to come up with a solution I can get to work. I need to create a unique id. I can do this using Dmax to find the...
0
7165
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,...
1
6887
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
7379
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...
1
4910
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...
0
3093
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3085
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1419
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
656
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
291
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.