SaM---
06-20-2001, 03:48 PM
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
06-20-2001, 06:42 PM
My guess is that your code in the NotInList event is incomplete. Post your code and maybe someone can spot your error.
SaM---
06-21-2001, 03:58 AM
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
06-21-2001, 04:15 AM
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---
06-25-2001, 06:38 AM
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
06-25-2001, 06:54 AM
What about just refreshing the form instead of saving the record...
Use me.Refresh
Doug
SaM---
06-25-2001, 12:24 PM
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