combo box new list being dupilcated

F

Fred

I have a combo box that a user picks and choose from a list. After the
selection is made it auto fills several text boxes. If the user can not find
a selection, they have the ability to add to the list. This works out great.
But I now have run into another problem where the new information is being
duplicated. The combo box created two new reference numbers for the new
information. I hoping someone can help me to change the code to create just
one reference number for the new information. The following is the code I am
using in the AfterUpdate and NotInList event procedures. Reference number is
an AutoNumber field. In advance Thanks!



Private Sub cboNames_AfterUpdate()

Me.patientbox = Me![cboNames].Column(0)
Me.MemberIDbox = Me![cboNames].Column(1)
Me.DOBbox = Me![cboNames].Column(2)
Me.Residencebox = Me![cboNames].Column(3)

End Sub


Private Sub cboNames_NotInList(NewData As String, Response As Integer)

Dim ctl As Control
Dim strSQL As String
Dim lngID As Long
Dim strDblQuote As String

strDblQuote = """"

Set ctl = Me!cboNames

lngID = DMax("[reference number]", "[tblMedical]") + 1

Response = acDataErrAdded

strSQL = "INSERT INTO [tblMedical]([reference number],[Patient])
VALUES("
strSQL = strSQL & lngID & "," & strDblQuote & NewData & strDblQuote &
");"
CurrentDb.Execute strSQL

End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top