feathers212
01-15-2007, 02:13 PM
I have a form that uses an unbound combo box to choose a material to receive. The material is choosen from a master list. Each material on the master list has it's own material ID which is set up as the primary key.
The form also has unbound text boxes for the date and quantity of the receipt. When the submit receipt button is clicked, the receipt is added to the transaction table:
Private Sub Submit_Receipt_Click()
On Error GoTo Err_Submit_Receipt_Click
Dim db As Database
Dim rs As Recordset
Set db = CurrentDb
Set rs = db.OpenRecordset("Material Transactions")
With rs
.AddNew
![Material Name] = Me.ReceiptMaterial.Value
![Date] = Me.ReceiptDate.Value
![Transaction] = "Receipt"
![Quantity] = Me.ReceiptQuantity.Value
.Update
.Close
End With
DoCmd.Close acForm, "Receipts Form", acSaveYes
MsgBox ("Receipt entered into database.")
Exit_Submit_Receipt_Click:
Exit Sub
Err_Submit_Receipt_Click:
MsgBox Err.Description
Resume Exit_Submit_Receipt_Click
End Sub
Everything works just fine, except for the Material Name portion. The programming enters in the associated material ID rather than the actual name that was chosen from the drop down.
I'm not sure about the Me.ReceiptMaterial.Value. Is this correct, or should I not be using the .Value?
The form also has unbound text boxes for the date and quantity of the receipt. When the submit receipt button is clicked, the receipt is added to the transaction table:
Private Sub Submit_Receipt_Click()
On Error GoTo Err_Submit_Receipt_Click
Dim db As Database
Dim rs As Recordset
Set db = CurrentDb
Set rs = db.OpenRecordset("Material Transactions")
With rs
.AddNew
![Material Name] = Me.ReceiptMaterial.Value
![Date] = Me.ReceiptDate.Value
![Transaction] = "Receipt"
![Quantity] = Me.ReceiptQuantity.Value
.Update
.Close
End With
DoCmd.Close acForm, "Receipts Form", acSaveYes
MsgBox ("Receipt entered into database.")
Exit_Submit_Receipt_Click:
Exit Sub
Err_Submit_Receipt_Click:
MsgBox Err.Description
Resume Exit_Submit_Receipt_Click
End Sub
Everything works just fine, except for the Material Name portion. The programming enters in the associated material ID rather than the actual name that was chosen from the drop down.
I'm not sure about the Me.ReceiptMaterial.Value. Is this correct, or should I not be using the .Value?