Hey all,
I'm making a Microsoft Access database for maintaining stock and purchasing etc. What I have at the moment is when you fill in the purchasing form, you click on the Submit button and that runs an append query appending certain information into another table - all that works fine.
However, I want to introduce a Quantity value. This is so when ordering - for example - 4 PCs, I can just fill in the Quantity field as 4, rather than having to enter all the information 4 times. In order to append it to the table, i've come up with the below code:
The problem I'm getting with it at the moment, is that it seems to be running an endless loop - it just sits there calculating for ages until I interrupt it.
Me.Quantity is the Quantity field on my form (which is obviously open when this code is run).
If anyone can help me with this, I'd greatly appreciate it.
Ta,
-Wills
I'm making a Microsoft Access database for maintaining stock and purchasing etc. What I have at the moment is when you fill in the purchasing form, you click on the Submit button and that runs an append query appending certain information into another table - all that works fine.
However, I want to introduce a Quantity value. This is so when ordering - for example - 4 PCs, I can just fill in the Quantity field as 4, rather than having to enter all the information 4 times. In order to append it to the table, i've come up with the below code:
Code:
Counter = 0
Do
Counter = Counter + 1
X = Me.Quantity.Value
SQL = "INSERT INTO tblAsset ( ID_Har_Pur, Description, Asset_Type ) " & _
"SELECT tblPurchasing.ID_Asset, tblPurchasing.Description, tblPurchasing.Purchase_Type " & _
"FROM tblPurchasing " & _
"WHERE (((tblPurchasing.Purchase_Type)='Hardware') AND ((tblPurchasing.ID_Pur)=[Forms]![frmPurchasingNew].[ID_Pur].[Value])) OR (((tblPurchasing.Purchase_Type)='Telecommunications')) OR (((tblPurchasing.Purchase_Type)='Technical Library')) OR (((tblPurchasing.Purchase_Type)='Equipment')) OR (((tblPurchasing.Purchase_Type)='Mobile'));"
DoCmd.RunSQL SQL
Loop While Counter <= X
MsgBox "Requisiton Submitted.", vbOKOnly
The problem I'm getting with it at the moment, is that it seems to be running an endless loop - it just sits there calculating for ages until I interrupt it.
Me.Quantity is the Quantity field on my form (which is obviously open when this code is run).
If anyone can help me with this, I'd greatly appreciate it.
Ta,
-Wills