Adding New Record Thru Combo Box

  • Thread starter Thread starter DesiGuju2004
  • Start date Start date
D

DesiGuju2004

Guest
Does anyone knows what's going on here ?

I have combo box on my main form and i'm using following code to add new record to combo box. Each time i add new record it adds to the table twice. For example if i put "XYZ" in combo box it would add new value to the combo box but when i go back in the table to see the value i will see XYZ twice as two different record.

Code:
Private Sub cboSAENo_NotInList(NewData As String, Response As Integer)

Dim strsql
    MsgBox "This SAE No does not exist.  Creating new Record."
    strsql = "Insert Into tblSAEs (SAENo, ParticipantsNo) values ('" & NewData & "','" & Me.cboParticipants & "')"
    CurrentDb.Execute strsql ', dbForwardOnly
    Response = acDataErrAdded
    
End Sub
 
Only thing I can think of is if you used the combo-box wizzard and then selected the 'Store the value on the following field' option, which would mean that the value is being stored once by the selection from the wizzard and once by your code.
 
daveUK,

Thanks for the response

I didn't use Access Wizard to generate the combo box. And the problem is still there. Any other suggestion ?
 
Desi,

I'd say that your combo box is bound to tblSAEs.
You don't have to do the Insert, just the requery.

Wayne
 
WayneRyan,

How do i re-query the combo box in NotInList event of combo box ?
 

Users who are viewing this thread

Back
Top Bottom