I am using Access 2000.
When I step through or run the code below and get to the "Dim db as Database" line, it gives me an error:
Microsoft Visual Basic: Compile Error - User-defined type not defined
Why? How can I fix this? Do you see any other glaring problems with my code?
Thanks in advance,
Jamie
' Option Compare Database
Private Sub AdjustInventory()
Dim db As Database
Dim rst As Recordset
Dim strSql As String
Dim Response As Integer
Set db = CurrentDb()
Set rst = db.OpenRecordest("QryQuantityProdOrdered")
With rst
If .RecordCount < 1 Then
.Close
Response = MsgBox("No Inventory Adjustments Requred", vbOKOnly, "No Inventory Adjustment")
End
Else
Do While Not .EOF
strSql = "Update TblProduct Set ProdNoInStock = ProdNoInStock - " & _
![SumOfQuantity] & " Where ProdID = " & ![ProdID]
db.Execute (strSql)
strSql = "Update TblOrderDetail Set AppliedToInventory = 'yes'" & _
" Where ProdID = " & ![ProdID] & " and AppliedToInventory = 'no'"
db.Execute (strSql)
.MoveNext
Loop
End If
End With
When I step through or run the code below and get to the "Dim db as Database" line, it gives me an error:
Microsoft Visual Basic: Compile Error - User-defined type not defined
Why? How can I fix this? Do you see any other glaring problems with my code?
Thanks in advance,
Jamie
' Option Compare Database
Private Sub AdjustInventory()
Dim db As Database
Dim rst As Recordset
Dim strSql As String
Dim Response As Integer
Set db = CurrentDb()
Set rst = db.OpenRecordest("QryQuantityProdOrdered")
With rst
If .RecordCount < 1 Then
.Close
Response = MsgBox("No Inventory Adjustments Requred", vbOKOnly, "No Inventory Adjustment")
End
Else
Do While Not .EOF
strSql = "Update TblProduct Set ProdNoInStock = ProdNoInStock - " & _
![SumOfQuantity] & " Where ProdID = " & ![ProdID]
db.Execute (strSql)
strSql = "Update TblOrderDetail Set AppliedToInventory = 'yes'" & _
" Where ProdID = " & ![ProdID] & " and AppliedToInventory = 'no'"
db.Execute (strSql)
.MoveNext
Loop
End If
End With