Form / Table help

jcaptchaos2

Well-known Member
Joined
Sep 24, 2002
Messages
1,032
Office Version
  1. 365
Platform
  1. Windows
I have a form where the user scans his ID and then a work order bar code which files in order number, item number and op number, he then enters with the keypad, good pcs, scrap pcs, selects a scrap reason code from a combo box and then selects the time the job was started. It also will add the current time, date and total time to the table automatically. My question is the person may have 5 scrap pcs for one reason and 1 scrap for another reason and so on, how can I make it so they would just have to enter the second scrap reason and pcs and not have to go through the whole for again? If I type it in now without scanning the other information it will leave blank cells in the table and will not be linked to the order, empl or item numbers. Would this be where I would use a subform?
 
If I click on the yellow arrow over to the left a brown dot will come up and then a brown line to the first letter of the code and the rest remains yellow.It will not step passed that line when pressing F8
 
Upvote 0

Excel Facts

Easy bullets in Excel
If you have a numeric keypad, press Alt+7 on numeric keypad to type a bullet in Excel.
and I also put the spaces back into the source names.
So the actual controls in the Design view would show in the properties window as Shop Floor Data Entry - with spaces?

That is one problem. Remove all spaces - so Shop Floor Data Entry should be renamed to ShopFloorDataEntry, or put underscores in place of the spaces. Just no spaces at all in the controls.

Secondly, I am not sure what you heard when I wrote explaining the process of the variables and such, but I just went back and saw that each of your variables is pulling from the same control. This is what it should look like:
Code:
Private Sub scrap_entry_Click()

Dim varEmployee_Number, varItem_Number, varShop_Order_Number, varOpNumber

a = MsgBox("Do you want to enter extra scrap codes?", vbYesNo)
If a = vbYes Then
    
    varEmployee_Number = Me!control1.Value
    varItem_Number = Me!control2.Value
    varShop_Order_Number = Me!control3.Value
    varOp_Number = Me!control4.Value
    
    RunCommand acCmdRecordsGoToNew
    
    Me!control1= varEmployee_Number
    Me!control2= varItem_Number
    Me!control3= varShop_Order_Number
    Me!control4= varOp_Number
    MsgBox ("Thank You")
    
End If
End Sub

Substitute control1, control2, control3, control4 with the actual names of the controls (remember change them to no spaces in design view). The first one should look like
Code:
varEmployee_Number = Me!ShopFloorDataEntry.Value

Unless ShopFloorDataEntry is the name of the form. If this is the case, then ignore that snippet and focus on what I wrote above.

Let me know if this helps clear things up.
 
Last edited:
Upvote 0
I really apologize for taking up so much of you time and want to thank you for sticking with this,

Yes the form name is Shop Floor Data Entry.
The table name that the data goes into is Shop Floor Data
the control source for the first text box is named Employee Number is EmployeeNumber now that I took the space out. Are you saying that the first line of code after
Code:
Private Sub scrap_entry_Click()

Dim varEmployee_Number, varItem_Number, varShop_Order_Number, varOpNumber

a = MsgBox("Do you want to enter extra scrap codes?", vbYesNo)
If a = vbYes Then

Should look like this?
Code:
varEmployeeNumber = Me!EmployeeNumber.Value
 
Upvote 0
Yes, that looks about right as long as your textbox that you are trying to get the value from is named EmployeeNumber. Another best practice in this area is to label your controls with a prefix. EmployeeNumber (if coming from a text box) would be labeled as txtEmployeeNumber. That way it helps you (and those after you) what is a variable and what is a control being refered to. Label would be lblLabel1, combobox = cmbChooseMe, you get the picture.

And it's no problem helping at all. We all begin somewhere! :)

You will want to rethink having spaces in both your form and table names as well. Spaces just cause a ton of issues if you are ever needing to use VBA (like we are in this case) and eliminating spaces is in best practices for Access db construction.

If you ever had to run code from one form to look/open/display on another form, you will run into some of the same problems by having spaces in your form name. Other errors for table names can come up as well.

Anyways, to further explain - Me! is the same as your form name "Shop Floor Data Entry" when on that form. If you were on Form1234, Me! would equal "Form1234." Me! is just a better quicker way of basically saying to the computer "This object."
 
Upvote 0
Ok here is what I did and it is somewhat working, I did this prior to reading your last advice, ME = Form Name should I change all the Me! to have the form name after them instead of what I got? What I listed below is working but not exactly how I want it, if you don't mid me asking a couple more questions.
Code:
Private Sub scrap_entry_Click()

Dim varEmployeeNumber, varItemNumber, varShopOrderNumber, varOpNumber

a = MsgBox("Do you want to enter extra scrap codes?", vbYesNo)
If a = vbYes Then
    
    varEmployeeNumber = Me!EmployeeNumber.Value
    varItemNumber = Me!ItemNumber.Value
    varShopOrderNumber = Me!ShopOrderNumber.Value
    varOpNumber = Me!OpNumber.Value
    
    RunCommand acCmdRecordsGoToNew
    
    Me!EmployeeNumber = varEmployeeNumber
    Me!ItemNumber = varItemNumber
    Me!ShopOrderNumber = varShopOrderNumber
    Me!OpNumber = varOpNumber
    MsgBox ("Thank You")
    
End If
End Sub
 
Upvote 0
Ok using the form name did not work but what I posted is working to the point that I understand it a little better, thanks for your help and patients, I do have a couple other questions but will post later if your ok with it. I will work with this to see if I can answer them on my own for now,
 
Upvote 0
If you got questions, hopefully I got answers! :) Feel free to post them as long as they pertain to the discussion at hand. If they are regarding an altogether different problem that we haven't discussed, you might be better off starting a new thread.
 
Upvote 0
I think I figured it out, just want to say thanks for all your help, I will be working on this database further tonight hope not to have to bother you any more.
 
Upvote 0
Ok one last question, can something be added to the code for that button that it wont let it enter data unless there is a qty in the scrap text box?
 
Upvote 0

Forum statistics

Threads
1,224,617
Messages
6,179,915
Members
452,949
Latest member
beartooth91

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top