Remove Text from Combo Box

danian

Registered User.
Local time
Today, 22:24
Joined
Jun 27, 2005
Messages
54
I have a combo box that I use a barcode scanner with. I scan the barcode and it finds the product using the code below:

Private Sub cmbBarCode_Click()
' ADD A TRANSACTION AUTOMATICALLY

Dim RS As ADODB.Recordset
Set RS = New ADODB.Recordset
RS.Open "SELECT * from tblTransactions", Application.CurrentProject.Connection, adOpenStatic, adLockOptimistic
RS.AddNew
RS!OrderID = ID
RS!Barcode = cmbBarcode.Column(0)
RS!Manufacturer = cmbBarcode.Column(1)
RS!ProductName = cmbBarcode.Column(2)
RS!QuantitySold = -1
RS!Cost = cmbBarcode.Column(4)
RS.Update
RS.Close
Set RS = Nothing
lstTransactions.Requery

End Sub


What I need to happen is all the above but after it has finished or before it starts it needs to clear the contents of the box. So the barcode is entered it runs the above script and then removes the barcode from the combo box, so I am ready to scan the next barcode.

Thanks,
Danian
 
I'd try...
Code:
Private Sub cmbBarCode_Click()
' ADD A TRANSACTION AUTOMATICALLY
  Dim RS As New ADODB.Recordset

  With RS
    .Open "SELECT * from tblTransactions", Application.CurrentProject.Connection, adOpenStatic, adLockOptimistic
    .AddNew
    !OrderID = ID
    !Barcode = cmbBarcode.Column(0)
    !Manufacturer = cmbBarcode.Column(1)
    !ProductName = cmbBarcode.Column(2)
    !QuantitySold = -1
    !Cost = cmbBarcode.Column(4)
    .Update
    .Close
  End With
  Set RS = Nothing
  lstTransactions.Requery

[COLOR=DarkRed]  cmbBarCode = Null[/COLOR]

End Sub
 
Thanks for the reply, that works great. The only problem I have now is that the barcode is entered and selects the product, it then removes the barcode but tabs down to the next textbox. I need it to stay in the same combo box cmbBarcode. I know this is simple, but I am not sure how to do it.

Thanks
D
 
Try...

Code:
  ...
  lstTransactions.Requery

[COLOR=DarkRed]  With Me.cmbBarCode
    .Value = Null
    .SetFocus
  End With
[/COLOR]
End Sub
 

Users who are viewing this thread

Back
Top Bottom