473,625 Members | 3,318 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Macro assigned to an update button

3 New Member
So.... I have an UpdateButton Macro assigned to my P.O. Generator, and want it to stop and ensure all fields are filled out prior to update.
Expand|Select|Wrap|Line Numbers
  1. Sub UpdateButton()
  2.   Application.ScreenUpdating = False
  3.   Dim copySheet As Worksheet
  4.   Dim pasteSheet As Worksheet
  5.  
  6.   Set copySheet = Worksheets("Purchase Order")
  7.   Set pasteSheet = Worksheets("PO Log")
  8.  
  9.   copySheet.Range("POnumber").Copy
  10.   pasteSheet.Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).PasteSpecial xlPasteValues
  11.   Application.CutCopyMode = False
  12.   Application.ScreenUpdating = True
  13.  
  14.   copySheet.Range("OrderSummary").Copy
  15.   pasteSheet.Cells(Rows.Count, 2).End(xlUp).Offset(1, 0).PasteSpecial xlPasteValues
  16.   Application.CutCopyMode = False
  17.   Application.ScreenUpdating = True
  18.  
  19.   copySheet.Range("POdate").Copy
  20.   pasteSheet.Cells(Rows.Count, 3).End(xlUp).Offset(1, 0).PasteSpecial xlPasteValues
  21.   Application.CutCopyMode = False
  22.   Application.ScreenUpdating = True
  23.  
  24.   copySheet.Range("RequestedBy").Copy
  25.   pasteSheet.Cells(Rows.Count, 4).End(xlUp).Offset(1, 0).PasteSpecial xlPasteValues
  26.   Application.CutCopyMode = False
  27.   Application.ScreenUpdating = True
  28.  
  29.   copySheet.Range("Vendor").Copy
  30.   pasteSheet.Cells(Rows.Count, 5).End(xlUp).Offset(1, 0).PasteSpecial xlPasteValues
  31.   Application.CutCopyMode = False
  32.   Application.ScreenUpdating = True
  33.  
  34.   copySheet.Range("DeliveryDate").Copy
  35.   pasteSheet.Cells(Rows.Count, 6).End(xlUp).Offset(1, 0).PasteSpecial xlPasteValues
  36.   Application.CutCopyMode = False
  37.   Application.ScreenUpdating = True
  38.  
  39.   copySheet.Range("Cost").Copy
  40.   pasteSheet.Cells(Rows.Count, 7).End(xlUp).Offset(1, 0).PasteSpecial xlPasteValues
  41.   Application.CutCopyMode = False
  42.   Application.ScreenUpdating = True
  43.  
  44.   Range("='Purchase Order'!$B$2:$N$47").PrintOut
  45.  
  46.   End Sub
  47.  
Nov 4 '19 #1
2 1497
Barracuda72
3 New Member
Okay... So I think I have figured part of it out with
Expand|Select|Wrap|Line Numbers
  1. If Cells(4, 3).Value = "" Then
  2. MsgBox "Requested By Requires User Input"
  3.  
  4. Cancel = True
  5. End If
But I would like this add-on to stop the updating process as well... HELP!!
Here's entire code with new MsgBox code.
Expand|Select|Wrap|Line Numbers
  1. Sub UpdateButton()
  2.   Application.ScreenUpdating = False
  3.   Dim copySheet As Worksheet
  4.   Dim pasteSheet As Worksheet
  5.  
  6.   Set copySheet = Worksheets("Purchase Order")
  7.   Set pasteSheet = Worksheets("PO Log")
  8.  
  9.   copySheet.Range("POnumber").Copy
  10.   pasteSheet.Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).PasteSpecial xlPasteValues
  11.   Application.CutCopyMode = False
  12.   Application.ScreenUpdating = True
  13.  
  14.   copySheet.Range("OrderSummary").Copy
  15.   pasteSheet.Cells(Rows.Count, 2).End(xlUp).Offset(1, 0).PasteSpecial xlPasteValues
  16.   Application.CutCopyMode = False
  17.   Application.ScreenUpdating = True
  18.  
  19.   copySheet.Range("POdate").Copy
  20.   pasteSheet.Cells(Rows.Count, 3).End(xlUp).Offset(1, 0).PasteSpecial xlPasteValues
  21.   Application.CutCopyMode = False
  22.   Application.ScreenUpdating = True
  23.  
  24.   copySheet.Range("RequestedBy").Copy
  25.   pasteSheet.Cells(Rows.Count, 4).End(xlUp).Offset(1, 0).PasteSpecial xlPasteValues
  26.   Application.CutCopyMode = False
  27.   Application.ScreenUpdating = True
  28.  
  29.   copySheet.Range("Vendor").Copy
  30.   pasteSheet.Cells(Rows.Count, 5).End(xlUp).Offset(1, 0).PasteSpecial xlPasteValues
  31.   Application.CutCopyMode = False
  32.   Application.ScreenUpdating = True
  33.  
  34.   copySheet.Range("DeliveryDate").Copy
  35.   pasteSheet.Cells(Rows.Count, 6).End(xlUp).Offset(1, 0).PasteSpecial xlPasteValues
  36.   Application.CutCopyMode = False
  37.   Application.ScreenUpdating = True
  38.  
  39.   copySheet.Range("Cost").Copy
  40.   pasteSheet.Cells(Rows.Count, 7).End(xlUp).Offset(1, 0).PasteSpecial xlPasteValues
  41.   Application.CutCopyMode = False
  42.   Application.ScreenUpdating = Tru
  43.  
  44. If Cells(4, 3).Value = "" Then
  45. MsgBox "Requested By Requires User Input"
  46.  
  47. Cancel = True
  48. End If
  49.  
  50. Range("='Purchase Order'!$B$2:$N$47").PrintOut
  51.  
  52.   End Sub
Nov 4 '19 #2
Barracuda72
3 New Member
For all that are interested.... The solution to my issue was
Expand|Select|Wrap|Line Numbers
  1.  
  2.  If IsEmpty(Range("OrderSummary")) Or IsEmpty(Range("RequestedBy")) Or IsEmpty(Range("POnumber")) Then
  3.  MsgBox "Information is Missing:Requested By, Order Summary, and P.O. Require User Input", vbRetryCancel
  4.  Exit Sub
  5.  End If
That is all...
Nov 6 '19 #3

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

Similar topics

4
2965
by: David Colliver | last post by:
Hi all, I am having a slight problem that hopefully, someone can help me fix. I have a form on a page. Many items on the form have validation controls attached. Also on this form are linkbuttons which must not cause validation. I have found a setting "causeValidation" to disable the validation. Also on the page, I have a datagrid that I will edit lines on. I can click
4
4675
by: J055 | last post by:
Hi I have 2 update buttons in my FormView ('Apply' and 'OK'). I want both buttons to update the data source but the 'OK' button should redirect afterwards. I can see which button is clicked in the ItemCommand event but I can't redirect from here because the ItemUpdated event hasn't fired yet. I can put a variable in the code-behind class which is gets the
0
2638
by: ayneekeaw | last post by:
When I click the update button/link at the Gridview to update the data from drop down list into the SQL. The selected value of drop down list change to default value. How can I fix this problem
0
1739
by: mesut | last post by:
Hi there, I've a question. I would like to create a global update button to update all changed records gridview. e.g. A gridview contains 5 columns an 2 of the columns can be updated by the user. (other 3 are readonly) e.g. a column called Status is a dropdownlistbox the user can choose a status of the product and the other column called instructions is a text box, the user can type in any value.
1
1362
by: schuiazza | last post by:
Hi, I am updating a webpage which displays information about electrical networks. The company requires to update gridstation information regarding voltage based on each are i..e south east etc, office i.e. different states in the country and each office i.e. local area. I have written button to add new gridstation but while for update button I am not get to get window popup for all offices, I am able to get popup only for penultimate...
1
2293
by: geeteshss | last post by:
Dear all, actually i spent a whole month on the R&D of datagrid edit ,update,cancel events but recently my guide told me to make it user friendly because no user would like to go on searching rows and columns in a datagrid if there are number of rows and columns.so in my web page i have got two labels two textboxes and three buttons namely add update and delete so when i click on the add button the data is added to datagrid and also displayed...
0
1422
by: stimul8d | last post by:
Before i get flamed, this isn't the usual question you see left right and center. I'm dynamically creating usercontrols inside the page_init event and setting the ID's of each control so that the events survive postback. in the user control i have a datagrid which uses the old databinding events (updating, editing etc,...). Here's the problem, the editing event fires but the updating event doen't. Take a look - This is the...
3
1213
by: shekharncst | last post by:
Hi I am using GridView in ASPX page <asp:GridView AutoGenerateEditButton ="false" id="siGridView" runat="server" Font-Names="Cordia New" Font-Size="Smaller" AllowSorting="True" AllowPaging ="true" PageSize="20" HorizontalAlign="left" onsorting="switchGridView_Sorting" ...
0
1066
by: Cad33ee | last post by:
Good Day! I Am using Microsoft Access 2016. I would like to know how can i create a simple update button. I already created add, clear and close. However, I do have a hard time on creating an update button which updates my table. I do also would like to know how to give conditions on text box which you can only input Numbers. Thanks in advance.
0
8256
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8694
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8356
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8497
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6118
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4089
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2621
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 we have to send another system
1
1803
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1500
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.