How to add fields and text boxes and assign control source to the.

S

SuperNerd

Hello, I have a form that I have created to do quality inspection on incoming
raw materials. What I want to do with this is to have the inspectors/users
first enter in the quantity recieved. With the quantity of the parts
recieved known, the program will know how many parts the inspector has to
inspect and from that, it will create the correct amount of input text boxes,
along with new fields, for the inpector to input in the inspected data.

In other words:
# of parts recieved will generate new fields and ,equally, text boxes for
inspection data.

for example: if 500 parts were recieved, the inspector will need to inspect
15 of the 500 parts to save time.

sorry for writing so much.
I hope this makes sense and is possible to do in MS Access. PLEASE HELP!!!

thanks dough
 
C

code_monkey_number_9

SuperNerd:

I suppose I would approach this by creating a related table to hold
inspection data for recieved products:

tblRecieved
ID | QTY | Data1 | etc

tblInspections
ID | ReceivedID | Data 1 | etc

Then create a subform based on tblInspections, and link it to your main
form. When the user enters a quantity, your code could run on the
after_update event:

Private Sub txtQTY_AfterUpdate()

'get the number of inspections for qty:
'insert whatever function you have for performing this logic
Dim qty as integer
qty = onGetInspectionsRequired (Me.txtQTY)

Dim x as integer
Dim str as string

For x = 1 to qty
str = "Insert Into tblInspections (ID, RecievedID) Values (" & x & ", " &
Me.ID & ");"
DoCmd.RunSQL str
Next

Me.subFrmInspections.Form.Requery 'or whatever. this statement may not be
syntactically correct, but the idea is

End Sub

Private Function onGetInspectionsRequired(qty as integer) as Integer

Select Case qty
Case <= 500
onGetInspectionsRequired = 15
Case > 500
onGetInspectionsRequired = 20
End Select

End Function
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top