Full Version: Command button to populate a field
UtterAccess Forums > Microsoft® Access > Access Forms
gadgetdiver
Hi,
work in a manufacturing environment & need to record when a process starts / ends on a particular machine.
The idea is, using a form an operator will scan a barcode & it will populate a job number field in a record.
There will also be 4 command buttons shown on the form, each one refers to a specific task.
i.e. setup start, setup stop, production run start, production run stop.
The operator is to click on a command button, & it then populates the process field.
It is the command button task I am unable to achieve.
I have a simple database structure.
Key Field
Job Number
Process
Date
Time
Any assistance would be greatly appreciated.
Gadgetdiver
MStef
Hello Gadgetdiver!
You said ;
"I have a simple database structure. Key Field, Job Number, Process, Date, Time", I suppose it is your table.
But, which of these fields is "SETUP START", which is "SETUP STOP", which is "PRODUCTION RUN START", which is
"PRODUCTION RUN STOP" ???
gadgetdiver
Hello,
orry, it all makes sense in my head!
I would like command button no 1 to be Setup Start, command button 2 to be Setup End, button 3 - Prod Run Start, button 4 - Prod Run End.
What I would like is when the operator clicks on the required command button, it places the fixed data (i.e. Setup Start) into the process field.
Apologies
Gadgetdiver
MStef
I asked you for field in the table, do you want to save these data in the table ??
gadgetdiver
Yes please!
MStef
But, which of these fields is "SETUP START", which is "SETUP STOP", which is "PRODUCTION RUN START", which is
"PRODUCTION RUN STOP" ???
gadgetdiver
Hi,
Sorry im not explaining myself very well.
The "Setup Start", "Setup Stop" etc. does not exist.
Oassumed, corectly or not, that you would be able to assign the fixed data i.e. "Setup Start" into a command button
and when selected it would populate the process field within the table with this fixed data.
Is this not the case, or have I completely missed the point & I am starting to annoy you. (which I sincerely hope im not)
MStef
OK here it is "DemoPopulateFieldA2000.mdb" (attachment, zip).
Open Form1 and try. I think it is what you need.
gadgetdiver
Hi, Thanks for the database. Its almost what I need. Would it be possible to record the data into a table. The data can then be used further down the line. I attach the file with some sample data.
any Thanks
kbrewster
Hi gadgetdiver,
ouple of things...
"Date" and "Time" are access reserved words and should be changed. You could just put the date and time in one field using and then if you need to extract each part you can do that when needed. Also, it is best not to use spaces in your field names.
Where does the Job Number come from? Since the form is unbound there is no way to pull the JobNumber? What you would need to do is write an INSERT statement for each command button which will insert the record.
Also, you would want to make sure that process was not already done before inserting the record.
Is there anyway you could upload your actual DB so that we could get a better idea of all of the tables you are dealing with?
gadgetdiver
Hello Kristen,
Thanks for the reply. Apologies if all this seems to be muddled, its been about a year since I last had a play with Access.
Ounderstand what you say regarding Date & Time and accept your solution, thank you.
The job number is a field which is to be scanned using a keyboard wedge scanner, which simulates a manual input.
I would then like the operator to click on 1 of 4 buttons, i.e. setup start, this will then transfer the data from behind the button to the record within the table, a date & time stamp will also be recorded.
A little later the operator will then click on another command buttopn, i.e. setup end.
I will admit I am at the very beginning of the design and have fallen at the first hurdle. I attach what I have.
Thank you in advance.
Gadgetdiver
kbrewster
Ok, just to let you know, you also should not use special characters when naming your objects ie:Date&Time.
nyways, this is the code I would use behind the Setup Start command button.
CODE
    If IsNull(Me.JobSheet) Or Me.JobSheet = "" Then
        MsgBox "You must first enter a Job Sheet number.", vbOKOnly + vbInformation
    Else
        Me.Process = "Setup Start"
        Me.ProcessDateTime = Now()
    End If

So then on each other button you could just change the Me.Process = "Setup Start" to whatever the name of the process is. You may also want to close the form as soon as the user has clicked the button so that they cannot click on it numerous time. I would also change the DataEntry property of the form to True so that it opens to a new record each time.
gadgetdiver
Hi Kristen,
It works perfectly, thank you so much!
Appreciate the advise ref operators clicking multiple times. My next task it to try & hide several command buttons once an operation has begun, and only leave one showing. i.e. once the have selected "Setup Start" hide all apart from "Setup End". I cannot belive how much work needs to be put in to stop operators clicking on the wrong button.
However, many thanks.
Gadgetdiver.
gadgetdiver
Hi Kristen,
further question if you wouldnt mind.
When I click on the command button for "Setup Start" the process, date & time appear in the form, however are not recorded in the table. When I click on "Setup End" it is recorded in the table. Is there a command I can insert that will record the data into the table when I click "Setup Start"
Thank you in advance
Gadgetdiver
This is a "lo-fi" version of UA. To view the full version with more information, formatting and images, please click here.