Re: Making ALL fields in a userform mandatory
Yes, he did. Thank you very much!
Re: Making ALL fields in a userform mandatory
Yes, he did. Thank you very much!
Is it possible to add code to an already existing script that encompasses ALL fields in the userform and makes them mandatory, or do I need to list each field separately in each form?
This question has been posted and answered at the following link.
Re: Command Button Security
THAT was the issue. It works great now! Thanks skywriter!!
Re: Command Button Security
What do you mean skywriter? I am new to this side of Excel and have been working with some other people to get this far.
Re: Command Button Security
Even though my username is in the list, I am still getting the Msgbox that I am not authorized. The ADDEXTEND in the name of the worksheet that this code is a part of.
I have a command button on a userform called "Approve". I have a list of users that are authorized to Approve any of the information that has been entered into the userform. I have attempted to write some code to handle it, but it is not working. When an authorized user clicks the "Approve" button the "Approved By" field on the userform should be populated with the Windows username. Can anyone take a look at the code and show me what is wrong? Thanks in advance!!
Private Sub CMB_Approve_Click()'Fill Approved By Field
Dim lRw As Long
Dim uName As String
With ADDEXTEND
lRw = .Cells(.Rows.Count, 1).End(xlUp).Row + 1
.Cells(2, 24).Value = Me.T_24.Value 'Change to corresponding cell
End With
Me.T_24.Value = Environ("Username")
Select Case uName
Case "Robert.Conklin", "Bill.Howell", "Tracy.Corbitt", "Danny.Crosby", "Mike.Dees", "Billy.Howell", _
"Tony.Thompson", "Ron.Lee", "Jerry.Hubbard", "Darrel.Funderburk", "Jason.Moseley", "Radley.Scott", _
"Vassel.Spencer", "Earl.Howell", "Anthony.Mack", "Jim.West", "Jeremy.Wilt", "Kenneth.Redd", _
"Graham.Brown", "Domingo.Malave", "Mike.Wester", "Howard.Hendon", "Steve.Barnes", "Troy.Thomas", _
"Euney.Fontenot", "Paul.Brown", "Darvis.Trahan", "Raul.Garcia", "John.Kocian", "Matt.Doris", "Mike.Kirk", _
"Richard.Stone", "Steve.King", "Stephan.Grigg", "Robert.Cooper", "Chris.Stewart", "Don.Ziegler", _
"Jon.Knoop", "Rick.Kocurek", "Brian.Rutecki", "Kenny.Johnson", "Kenyon.Baker", "Gerald.Burt", _
"Victor.Aldana", "Billy.Reese", "Mike.Nagel", "Andy.Kelly", "Mike.Sulzbach", "Patrick.Dashnaw", _
"Carl.McMahan", "Rob.Clamp", "Alan.Wilson", "Robert.Faulk", "Armand.Kelle", "Victor.Romero", "Cain.Soto", _
"Mike.Huston", "Tom.Raggousis", "Keith.Palmer", "Monty.Wood", "Henry.Staley", "Rick.Dubois", _
"Harold.Wyman", "Steve.Bly", "Tom.Ladd", "Bill.Morrow", "Ron.Porter", "Joseph.Richard", "Angel.Sanchez", _
"Jaime.Santacruz", "John.Luck", "John.Uzell", "Doug.Meyer", "Ray.Taylor", "Tommy.Garrett", _
"Chad.Harland", "Scott.Pate", "Paul.LaFond", "Chuck.Harrity", "Tim.DuBose", "Rick.Stolarik", "Dan.Bader", _
"Johnny.Oliver", "Jeff.Daugherty", "Jerry.Lambert", "Justin.Smith", "David.Seay", "David.Phillips", _
"Brad.Akers", "Matt.Fountain", "Joe.Hicks", "Wesley.Knapp", "Joey.Bovona", "Colt.Burris", "John.Pacheco", _
"Frank.Palmer", "Ronnie.Kilgore", "Dana.Taylor", "Tom.Hundley", "Dorman.Karr", "Paul.Staats", _
"Steve.Johnson", "Ricky.Dixon", "Les.Parrish", "Terry.Simmons", "Chad.Metevier", "Ciro.Garcia", _
"Steve.Nichols", "Danny.Bennett", "Randy.Johnson"
Case Else
MsgBox ("You Are Not Authorized")
End Select
End Sub
Display More
Re: Auto-Fill Userform Text Boxes based on a Combobox selection
Ok, I figured out the above. I just deleted the field and created a new one. Now it works fine. Now, for some reason in the code above, the ID field does not cycle to the next number after an entry is sent and the List Box "Click to Review" field is not populating. Any suggestions?
I also noticed that you inserted a table into the worksheet. How did you set that up?
Re: Auto-Fill Userform Text Boxes based on a Combobox selection
Hey Dotchiejack, I have begun implementing code to the rest of my project. Can you take a look at this code and tell me why I am unable to enter data into my "New Part Description" field (T_10)?
Option Explicit Dim Rng As Range, fnd As Range
Dim Ctrl As Control
Dim iRow As Long
Dim wsAE As Worksheet
Private Sub C_02_Click()
T_02.Value = C_02.Column(1)
End Sub
Private Sub CMB_AddNew_Click()
Set wsAE = Worksheets("DESCRIPTION CHANGES")
If MsgBox("Correct entry?", vbYesNo + vbQuestion, "Check the data!") = vbNo Then Exit Sub
iRow = wsAE.Cells.Find(What:="*", SearchOrder:=xlRows, SearchDirection:=xlPrevious, LookIn:=xlValues).Row + 1
wsAE.Cells(iRow, 1).Resize(, 34).Value = Array(T_id.Value, T_04.Value, C_02.Value, T_02.Value, T_08.Value, _
T_10.Value, T_11.Value, T_01.Value, T_23.Value, T_25.Value)
'Columns.AutoFit
MsgBox "The new entry has been saved.", vbInformation, "Done"
For Each Ctrl In Controls
If TypeName(Ctrl) = "TextBox" Or TypeName(Ctrl) = "ComboBox" Then Ctrl.Value = ""
Next Ctrl
LB_01.ListIndex = -1
LB_01.TopIndex = 0
Call UserForm_Initialize
End Sub
Private Sub CMB_Change_Click()
Set wsAE = Worksheets("DESCRIPTION CHANGES")
Set Rng = wsAE.Range("A2:A" & wsAE.Cells(Rows.Count, "A").End(xlUp).Row)
Set fnd = Rng.Find(What:=T_id.Value, LookIn:=xlValues, Lookat:=xlWhole)
If LB_01.ListIndex = -1 Then
MsgBox "First choose a item in the list!", vbCritical, "Attention!"
Exit Sub
Else
If T_id = vbNullString Then
MsgBox "Customizing is not possible, no entries found", vbExclamation, "Attention!"
Exit Sub
ElseIf Not fnd Is Nothing Then
Application.EnableEvents = False
If MsgBox("Correct entry?", vbYesNo + vbQuestion, "Check the data!") = vbNo Then Exit Sub
wsAE.Cells(fnd.Row, "A").Resize(, 34).Value = Array(T_id.Value, T_04.Value, C_02.Value, T_02.Value, T_08.Value, _
T_10.Value, T_11.Value, T_01.Value, T_23.Value, T_25.Value)
'Columns.AutoFit
MsgBox "The changes have been saved.", vbInformation, "Done"
Application.EnableEvents = True
End If
For Each Ctrl In Controls
If TypeName(Ctrl) = "TextBox" Or TypeName(Ctrl) = "ComboBox" Then Ctrl.Value = ""
Next Ctrl
LB_01.ListIndex = -1
LB_01.TopIndex = 0
Call UserForm_Initialize
End If
End Sub
Private Sub CMB_Clear_Click()
For Each Ctrl In Controls
If TypeName(Ctrl) = "TextBox" Or TypeName(Ctrl) = "ComboBox" Then Ctrl.Value = ""
Next Ctrl
LB_01.ListIndex = -1
LB_01.TopIndex = 0
Call UserForm_Initialize
End Sub
Private Sub CMB_Close_Click()
Unload Me
End Sub
Private Sub LB_01_Click()
T_id.Value = LB_01.Column(0)
T_04.Value = LB_01.Column(1)
C_02.Value = LB_01.Column(2)
T_02.Value = LB_01.Column(3)
T_08.Value = LB_01.Column(4)
T_10.Value = LB_01.Column(5)
T_11.Value = LB_01.Column(6)
T_01.Value = LB_01.Column(7)
T_23.Value = LB_01.Column(8)
T_25.Value = LB_01.Column(9)
End Sub
Private Sub UserForm_Initialize()
T_id.Value = WorksheetFunction.Max([ids]) + 1
LB_01.List = [database].Value
C_02.List = [datalist].Value
T_01.Value = Now
T_23.Value = Environ("Username")
End Sub
'
Display More
With the help of others, I have created a workbook for my end users that allows them to submit spare part maintenance requests. The problem lies in the fact that we have 48 different locations that will be submitting these requests. Is it possible to create a command button that will only work for specified Windows user names, that when clicked will copy all of the data from the workbook to another workbook on a shared drive? In order to satisfy our internal audit we have to be able to track all of the changes, and having one location to look would take care of that.
Re: Auto-Fill Userform Text Boxes based on a Combobox selection
GREAT NEWS!! I was able to figure out myself how do correct all of the above. I left the "Change" Command button because I figured out how to use it. I added code to fill in the "Lot Size" field. I also added the "Approve" command button and the code to make it work. Will take a look at the code and make sure that everything looks ok?
Re: Auto-Fill Userform Text Boxes based on a Combobox selection
Ok, I tried the code in my spreadsheet, but it is still not working. I will make this simple on both of us. I am going to use your original spreadsheet. Everything is already working and I am running out of time. I would like to make a few changes.
1. I would like to condensed the Equip. Functional Location fields (down from 6 to 1. I will have the end users separate each number with a comma. That will cut out the concatenated field on the user form and the extra columns in the worksheet.
2. The "Lot Size" (T_11) needs to autofill with "HB" when "VB" is selected in the "MRP Type" combobox.
3. I would like to change the "Change" command button to "Approve" and when clicked autofill the "Approved By" field (T_24) and the cells in column X on the ADD-Extend worksheet.
4. Can you label what each sub does so I can reference it for the other worksheets involved in this project?
Re: Auto-Fill Userform Text Boxes based on a Combobox selection
My apologies royUK. I am not familiar with the difference. I was trying to shorten the code myself, but I understand. Thank you for your help.
Re: Auto-Fill Userform Text Boxes based on a Combobox selection
Thanks for the tip dotchiejack! I tried to incorporate your code into my workbook to fill my LBL_Review field like you did your LB_01 field, but I am missing something...
Private Sub LBL_Review_Click()'Fill LBL_Review Field
TB_ID.Value = LBL_Review.Column(0)
Plant_Name.Value = LBL_Review.Column(1)
Plant_Number.Value = LBL_Review.Column(2)
Indicate_Action.Value = LBL_Review.Column(3)
SAP_Number.Value = LBL_Review.Column(4)
Purchasing_Group.Value = LBL_Review.Column(5)
Profit_Center.Value = LBL_Review.Column(6)
BUoM.Value = LBL_Review.Column(7)
MRP_Type.Value = LBL_Review.Column(8)
Lot_Size.Value = LBL_Review.Column(9)
CB_Noun.Value = LBL_Review.Column(10)
TB_Manufacturer.Value = LBL_Review.Column(11)
Manufacturer_PN.Value = LBL_Review.Column(12)
Extra_Desription.Value = LBL_Review.Column(13)
NEW_Part_Description.Value = LBL_Review.Column(14)
SAP_Part_Description.Value = LBL_Review.Column(15)
Minimum_Stock_Level.Value = LBL_Review.Column(16)
Maximum_Stock_Level.Value = LBL_Review.Column(17)
Storage_Bin_Location.Value = LBL_Review.Column(18)
Material_Group.Value = LBL_Review.Column(19)
Equip_Number_Loc.Value = LBL_Review.Column(20)
Parts_Added_to_BOM.Value = LBL_Review.Column(21)
Created_By.Value = LBL_Review.Column(22)
TB_Approved_By.Value = LBL_Review.Column(23)
Date Created.Value = LBL_Review.Column(24)
TB_Comments.Value = LBL_Review.Column(25)
SAP_Vendor_Number.Value = LBL_Review.Column(26)
TB_MODIFIER.Value = LBL_Review.Column(27)
End Sub
Display More
Also, I tried to use your code for what I think is the "Clear Fields" command button, but that is not working either.
Private Sub_CMB_Clear_Click()'Clear ALL Fields
For Each Ctrl In Controls
If TypeName(Ctrl) = "TextBox" Or TypeName(Ctrl) = "Combobox" Then Ctrl.Value = ""
Next Ctrl
LBL_Review.ListIndex = -1
LBL_Review.TopIndex = 0
Call UserForm_Initialize
End Sub
I was however able to get the "Approve" button to work, but not exactly like I would have it. I would like it to post to the Approved By field in the userform, and its respective cell in the ADD-EXTEND worksheet as well. As it stands right now, when I click Approve, it posts it to the Approved By field, and then I click submit to post the same to the worksheet.
I also was not able to decipher the code to get the ID to post automatically or the userform to clear whenever the "Submit Button" is clicked. I liked the pop up confirmation messages also.
Re: Auto-Fill Userform Text Boxes based on a Combobox selection
Gentlemen, this was not supposed to turn into a pissing match. I apologize if I turned it into one. From what I have learned, there are many different ways to get to what you want to do in VBA, and you two both have a different way to get there. They are both right, and they both work. But for my immediate needs, the shorter and clearer the better. Both of you have helped me more than I can ever say. I have learned from both of you. As I have told royUK, I am learning VBA, but the time frame that I have to complete this project is too short for me to get a solid grasp on the language in order to complete it myself. This is the reason I have been asking so many questions. As of today, I only have two more weeks to complete the project and what we have been working on is the bulk. I can hopefully take what you guys have helped with and what I have learned and apply it to the rest of the larger workbook. Again, I apologize if I started any trouble.
Re: Auto-Fill Userform Text Boxes based on a Combobox selection
Now why would I be getting an error message when I copy/pasted the code from the "Short Code" spreadsheet above to another spreadsheet and set it up exactly like the above spreadsheet. When I click the Add-Extend button I get the following error message:
Run-time Error '424'
Object Required
It points to the 'Sub Userform_Activate()' and references line 'Me.Plant_Name.List = Range(Cells(2, 2), .Cells(.Rows.Count,1).end(X1UP)).Value'
Both workbooks are identical, but the newer version gives the error message.
Re: Auto-Fill Userform Text Boxes based on a Combobox selection
Thanks to the phenomenal coding by dotchiejack, I was able to take what I learned from his code (which to be honest was a bit intimidating), but was able to apply some of it to royUK's more condensed code almost to completion.
The only thing I lack is the ID field and how it works.
The LBL_Review field at the bottom of the userform and how it works.
The close button should close the userform.
The clear fields button should clear the userform, but keep the same ID number.
Also, instead of a Change button, I would like to change it to an Approve button that would fill in the Approved By field with the windows username. The kicker is, that button should only be used certain people who have authorization to approve the requests.
The workbook labeled "Long Code" is what dotchiejack created, and it works like a champ. My goal is to get the same thing working in the "Short Code" workbook but in a condensed easy to understand code. Again, I REALLY appreciate everything that you guys have done and are doing to help!!
Re: Auto-Fill Userform Text Boxes based on a Combobox selection
Ok, I have moved all of my other worksheets to the working copy that you sent me. I have not changed anything in your code other than adding the date and time to the Userform_Initialized sub and make some corrections to the cell placement in LB_01_Click sub. Now when I click an entry in the "Click to Change" box at the bottom, I get the following error.
Run-time Error '-2147352571 (80020005)'
Could not set the value property. Type Mismatch
The error message is in the LB_01_Click sub, line T_21.Value = LB_01.Column(33). I looked at both the value on the worksheet and the value in the property box for the textbox and they match. What am I missing?
Re: Auto-Fill Userform Text Boxes based on a Combobox selection
That works perfectly! Thank you!
Re: Push Data entered on a userform to their respective locations on other worksheets
These issues have been cleaned up on the other post (http://www.ozgrid.com/forum/showthread.php?t=204573&page=2). Thank you for ALL your help!
Re: Auto-Fill Userform Text Boxes based on a Combobox selection
No problem Roy, I completely understand! I am currently without internet at my home due to a lightning strike. So I understand. Dotchiejack has been helping me out. Take a look at his spreadsheet above and let me know what you think?