Re: Proper using of Combobox
- From: "Ken Snell \(MVP\)" <kthsneisllis9@xxxxxxxxxxxxxxxxxx>
- Date: Sat, 4 Oct 2008 11:08:23 -0400
Show us the RowSource query for the combobox. And the ControlSource for the
combobox.
Also, are you saying that your combobox's NotInList code is adding two
records to the tbClientList table? I'm not fully understanding your
reference to "two records".
--
Ken Snell
<MS ACCESS MVP>
"Mishanya" <Mishanya@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:91852B04-DF56-45C9-8C21-B4D5640888D9@xxxxxxxxxxxxxxxx
I have frmClientDetails based on tblClientDetails, where the field
cboClientName in the form is a ComboBox, based on the fldClientName in the
table. E.g. I want to be able to either look or update the details by
picking
the already existing ClientName, or to add a new ClientName and all his
details.
In order to enable adding a new ClientName I try to use NotInList event of
the cboClientName in the form as follows:
Private Sub cboClientName_NotInList(NewData As String, Response As
Integer)
Dim strSQL As String
Dim i As Integer
Dim Msg As String
'Exit this sub if the combo box is cleared
If NewData = "" Then Exit Sub
Msg = "'" & NewData & "' is not currently in the list." & vbCr & vbCr
Msg = Msg & "Do you want to add it?"
i = MsgBox(Msg, vbQuestion + vbYesNo, "Unknown Book Category...")
If i = vbYes Then
strSQL = "Insert Into tblClientDetails ([ClientName]) " & _
"values ('" & NewData & "');"
CurrentDb.Execute strSQL, dbFailOnError
Response = acDataErrAdded
Else
Response = acDataErrContinue
End If
End Sub
Well, it does not work - it does enable to add a new name, but it also
adds
another record named by the ClientID automatic number wich was nominated
to
the record I'd tried to add, and nominates it with the next automatic
number.
So, by the end of the process I have 2 new ClientName-records in the
tblClientDetails (1 of wich is "fake") but still can not view them in the
frmClientDetails, as if there are no records.
I wonder, whether I have a basic mistake in ComboBox logic (e.g. it can
not
be based on and store the new value in the same field, so I have to create
an
additional tblClientName and base the fldClientName of the
frmClientDetails
on it) or i just have to handle the NotInList event right?
.
- Follow-Ups:
- Re: Proper using of Combobox
- From: Mishanya
- Re: Proper using of Combobox
- References:
- Proper using of Combobox
- From: Mishanya
- Proper using of Combobox
- Prev by Date: Re: Name Stamp export to Excel
- Next by Date: Re: Passing Data from One Form to Another, Variation on a Theme
- Previous by thread: Proper using of Combobox
- Next by thread: Re: Proper using of Combobox
- Index(es):
Relevant Pages
|