Robert Dunstan
Mr Data
- Local time
- Today, 22:57
- Joined
- Jun 22, 2000
- Messages
- 291
Hi guys
I have a bit of a problem which I hope someone can help me out with.
I have a main form (frmGoodsReceived) and a subform (frmGoodsReceivedDetailsSubform) both linked on OrderID. Basically this form allows the user to select an order, load the details of that order into the subform and enter the goods received.
What I'm trying to write is a routine that will loop the records of subform for that order and set the value quantity received field to the value of the quantity ordered field. The code has been written in the OnClick event of cmdAllReceived and this button is on the main form. The code I'm using is below:
Private Sub cmdAllReceived_Click()
Dim rst As Recordset
Dim ctlQuantity As Control
Dim ctlReceived As Control
Set rst = Forms!frmGoodsReceived!frmGoodsReceivedDetailsSubform.Form.Recordset
Set ctlQuantity = Forms!frmGoodsReceived!frmGoodsReceivedDetailsSubform.Form!txtQuantity
Set ctlReceived = Forms!frmGoodsReceived!frmGoodsReceivedDetailsSubform.Form!txtReceived
Do While Not rst.EOF And Me.OrderID = Forms!frmGoodsReceived!frmGoodsReceivedDetailsSubform.Form!OrderID
If Not IsNull(ctlQuantity) = True Then
ctlReceived.Value = ctlQuantity.Value
End If
Loop
End Sub
When I click on cmdAllReceived Access just hangs and I have to close it through Task Manager so I'm not even getting any error messages. I'm obviously doing something wrong so if someone could give me some guidance I would be extremely grateful.
I have a bit of a problem which I hope someone can help me out with.
I have a main form (frmGoodsReceived) and a subform (frmGoodsReceivedDetailsSubform) both linked on OrderID. Basically this form allows the user to select an order, load the details of that order into the subform and enter the goods received.
What I'm trying to write is a routine that will loop the records of subform for that order and set the value quantity received field to the value of the quantity ordered field. The code has been written in the OnClick event of cmdAllReceived and this button is on the main form. The code I'm using is below:
Private Sub cmdAllReceived_Click()
Dim rst As Recordset
Dim ctlQuantity As Control
Dim ctlReceived As Control
Set rst = Forms!frmGoodsReceived!frmGoodsReceivedDetailsSubform.Form.Recordset
Set ctlQuantity = Forms!frmGoodsReceived!frmGoodsReceivedDetailsSubform.Form!txtQuantity
Set ctlReceived = Forms!frmGoodsReceived!frmGoodsReceivedDetailsSubform.Form!txtReceived
Do While Not rst.EOF And Me.OrderID = Forms!frmGoodsReceived!frmGoodsReceivedDetailsSubform.Form!OrderID
If Not IsNull(ctlQuantity) = True Then
ctlReceived.Value = ctlQuantity.Value
End If
Loop
End Sub
When I click on cmdAllReceived Access just hangs and I have to close it through Task Manager so I'm not even getting any error messages. I'm obviously doing something wrong so if someone could give me some guidance I would be extremely grateful.