Hi all,
I have a form for entering products into an invoice, I have a datasheet and I start typing the product code in the box and if it exists in the database, it autocompletes the field, then populates the other columns with the product description, price, etc.
If the product code doesn't exist, it asks me if I want to add the product.
This is where the problems start - firstly, I have to manually type in the product code again, I would like it to copy over automatically.
Secondly, once I've added the new product and closed the form, I go back to the Invoice and I have to delete the product code, select an existing product (else it brings up the "Not In List, would you like to add?" thing again), then delete that product and re-type the product code of the new records. It doesn't refresh the query despite having a Refresh in there.
Here are my various codes...pretty simple, but then I am a beginner at this stuff:
Firstly from my invoicing form - called PartsSubForm:
And from the Products form, aka, the form I use to view, add, edit and delete products:
I have a form for entering products into an invoice, I have a datasheet and I start typing the product code in the box and if it exists in the database, it autocompletes the field, then populates the other columns with the product description, price, etc.
If the product code doesn't exist, it asks me if I want to add the product.
This is where the problems start - firstly, I have to manually type in the product code again, I would like it to copy over automatically.
Secondly, once I've added the new product and closed the form, I go back to the Invoice and I have to delete the product code, select an existing product (else it brings up the "Not In List, would you like to add?" thing again), then delete that product and re-type the product code of the new records. It doesn't refresh the query despite having a Refresh in there.
Here are my various codes...pretty simple, but then I am a beginner at this stuff:
Firstly from my invoicing form - called PartsSubForm:
Code:
Private Sub ProductCode_NotInList(NewData As String, Response As Integer)
Dim ctl As Control
'Suppress the default error message.
Response = acDataErrContinue
' Prompt user to verify they wish to add new value.
If MsgBox("Would you like to add this product to the database?", _
vbOKCancel) = vbOK Then
' open form to populate the various fields and carry up a new piece of the record
DoCmd.OpenForm "Products", , , , acFormAdd
Else
' If user chooses Cancel, suppress error message
' and undo changes.
Response = acDataErrContinue
End If
End Sub
Code:
Private Sub ProductCode_GotFocus()
Me.Refresh
End Sub
Code:
Private Sub ProductCode_AfterUpdate()
Me.ProductDescription = Me.[ProductCode].Column(2)
Me.CostPrice = Me.[ProductCode].Column(3)
Me.SalePrice = Me.[ProductCode].Column(4)
Me.Quantity = "1"
End Sub
And from the Products form, aka, the form I use to view, add, edit and delete products:
Code:
Private Sub Form_Close()
DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
End Sub