Strange behavior of combo box

SaM---

New member
Local time
Today, 23:57
Joined
Jun 20, 2001
Messages
5
Hi,
I think I need some help. Here's what I've got.

I think it's fairly simple.

Table : Cust
Field CustId
Name
Descr

Form 1 comboBox browsing Cust.CustId
2 input ( 1 Name, 1 Descr)

when I type a new custId in the combo box, my notinlist event ad it correctly, but for some reason , it won't take the good value in Name and descr.

Any Idea ?

Thanks

Sam
 
My guess is that your code in the NotInList event is incomplete. Post your code and maybe someone can spot your error.
 
Private Sub no_paquet_NotInList(NewData As String, Response As Integer)
Dim ctl As Control
Dim strsql As String

'Return control object that points to combo box
Set ctl = Me!no_paquet
'prompt user to verigy they wish to add a new value.
If MsgBox("Item is not in list. Add it?", vbOKCancel) = vbOK Then
'set response argument to indicate that data is being added.
Response = acDataErrAdded
'Add string in newdata argument to products tables.
NewData = StrConv(NewData, 3)
strsql = "INSERT INTO Cust(custid) SELECT'" & NewData & "'"
DoCmd.SetWarnings False
DoCmd.RunSQL strsql
ctl.Value = NewData
DoCmd.SetWarnings True
Else
'If the user choose cancel,suppress error message and undo changes.
Response = acDataErrContinue
crl.Undo
End If
exit_no_paquet_NotInList:
Exit Sub
err_no_paquet_notinlist:
If Err = 2113 Then
Err = 0
Resume Next
Else
MsgBox Str(Err)
MsgBox Err.Description
Resume exit_no_paquet_NotInList
End If
End Sub
 
Hi SaM---

Perhaps you need to save the new record first - try adding:

DoCmd.RunCommand acCmdSaveRecord

after

DoCmd.SetWarnings True

This will save the record before you go into the other fields to add data.

HTH


Rich Gorvin
 
thanks, now for some reason, when i'm done adding the record. My form will go back to the first record. So I can't update the one I've just entered. ??

Any Idea ??
 
What about just refreshing the form instead of saving the record...

Use me.Refresh

Doug
 
This is what is happening.
I add one customer number.
after I want to update his name.
In the bottom of my form, I can see that I now have 1 more record. But if I select the record I've just add, It will show that I'm updating the first record ? WTF ?

Thanks for your help.
Sam
 

Users who are viewing this thread

Back
Top Bottom