Strange behavior of combo box (1 Viewer)

SaM---

New member
Local time
Today, 22:30
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
 

Jack Cowley

Registered User.
Local time
Today, 22:30
Joined
Aug 7, 2000
Messages
2,639
My guess is that your code in the NotInList event is incomplete. Post your code and maybe someone can spot your error.
 

SaM---

New member
Local time
Today, 22:30
Joined
Jun 20, 2001
Messages
5
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
 

Rich@ITTC

Registered User.
Local time
Today, 22:30
Joined
Jul 13, 2000
Messages
237
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
 

SaM---

New member
Local time
Today, 22:30
Joined
Jun 20, 2001
Messages
5
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 ??
 

D-Fresh

Registered User.
Local time
Today, 22:30
Joined
Jun 6, 2000
Messages
225
What about just refreshing the form instead of saving the record...

Use me.Refresh

Doug
 

SaM---

New member
Local time
Today, 22:30
Joined
Jun 20, 2001
Messages
5
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

Top Bottom