FurryGorilla
Technical User
Hi
Just having a little problem with moving through records in a subform in datasheet view.
I have an order form which scrolls through individual orders. When you scroll through each of the orders the items on each order are displayed in the frmOrderItems which is a subform of frmOrders
When the user is to click on a button on the main form, calculations are to be carried out on each of the items in the subform for checking stock levels, quantities, etc.
The code for the button is as follows:
I've cut some of the code out to make it easier to read. I've had a look on some other posts and seen that people have suggested using
and then using a loop to go through the rest of the records in the subform. The problem I'm having is that if you have more than one order in the system which have items on these orders you get an error saying you can't access a the record. Is there a way to get it to only check the records on the subform of the particular order or will it always try to check the other orders?
Just to let you know I have a tblOrders, tblOrderItems and tblStock.. The subform has an SQL query as it's data source which returns the StockID, Name, Qty/Length from the tblOrderItems and tblStock and only shows the records where the txtOrderNo from frmOrders matches up with the OrderNo from tblOrderItems.
Hopefully I've explained myself clearly and any help would be much appreciated.
Many thanks
Chris ____________________________
Have you seen my munkee?![[monkey] [monkey] [monkey]](/data/assets/smilies/monkey.gif)
Just having a little problem with moving through records in a subform in datasheet view.
I have an order form which scrolls through individual orders. When you scroll through each of the orders the items on each order are displayed in the frmOrderItems which is a subform of frmOrders
When the user is to click on a button on the main form, calculations are to be carried out on each of the items in the subform for checking stock levels, quantities, etc.
The code for the button is as follows:
Code:
Private Sub btnTest_Click()
On Error GoTo Err_btnTest_Click
frmOrderItems.SetFocus
DoCmd.GoToRecord , , acFirst ' Go to first record in subform
Do....
Some calculations and such in here
DoCmd.GoToRecord , , acNext
Loop
DoCmd.GoToRecord , , acLast
Some calculations and such here
Exit_btnTest_Click:
Exit Sub
Err_btnTest_Click:
MsgBox Err.Description
Resume Exit_btnTest_Click
End Sub
I've cut some of the code out to make it easier to read. I've had a look on some other posts and seen that people have suggested using
Code:
DoCmd.GoToRecord , , acFirst
Just to let you know I have a tblOrders, tblOrderItems and tblStock.. The subform has an SQL query as it's data source which returns the StockID, Name, Qty/Length from the tblOrderItems and tblStock and only shows the records where the txtOrderNo from frmOrders matches up with the OrderNo from tblOrderItems.
Hopefully I've explained myself clearly and any help would be much appreciated.
Many thanks
Chris ____________________________
Have you seen my munkee?
![[monkey] [monkey] [monkey]](/data/assets/smilies/monkey.gif)