Re: Combo "Not in List Event", MS generic message still appears
- From: MikeJohnB <MikeJohnB@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Thu, 1 Jan 2009 04:11:01 -0800
I have looked carefully at your code and for the moment, I cannot see why
your dropping out of the Else line code into the error code.
I use the following amended code which works
Private Sub ComboSearchCusPtNo_NotInList(NewData As String, Response As
Integer)
Dim Db As DAO.Database
Dim rs As DAO.Recordset
Dim Msg1 As String
Msg1 = "'" & NewData & "' is not in the list." & vbCr & vbCr
Msg1 = Msg & "Do you want to add it?"
If MsgBox(Msg1, vbQuestion + vbYesNo) = vbNo Then
Response1 = acDataErrContinue
MsgBox "Try again."
Exit Sub
Else
Dim Message1, Title1, Default1, MyValue1
Message1 = "Enter a Part Description" ' Set prompt.
Title1 = "Enter Part Name" ' Set title.
Default1 = "BONDED SEAL" ' Set default.
MyValue1 = InputBox(Message1, Title1, Default1)
Message1 = "HINT" & Chr(13) & "Enter a Customer's Description
where Known" & Chr(13) & "This is Normally a Customer's Part Number Link" &
Chr(13) & "To Newtown Part Number, Enter Newtown Part No" & Chr(13) & "If it
is known"
'(the above is one line)
Default1 = "Bonded Seal"
Myvalue2 = InputBox(Message1, Title1, Default1)
Set Db = CurrentDb
Set rs = Db.OpenRecordset("Tbl_Cus_Part_Numbers", dbOpenDynaset)
rs.AddNew
rs![Customer_Part_Number] = NewData
rs![Description] = MyValue1
rs![CustomerDescription] = Myvalue2
rs.Update
Response = acDataErrAdded
End If
End Sub
In the above, which is the same code base as yours, I have added more fields
to add to the underlying table.
I post this in case you can either modify it or use it to determin where
your error is?
Kindest Regards
Mike B
--
Advice to Posters.
Check your post for replies or request for more information.
Consider providing some feed back to the response you have recieved.
Kindest Regards Mike B
"basiltabethacat via AccessMonster.com" wrote:
Thank you both for your time..
I tried "The Access Web" option (the first link) code:
Private Sub cboPlanName_NotInList(NewData As String, Response As Integer)
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim strMsg As String
strMsg = "'" & NewData & "' is not an available Unit Plan. " & vbCrLf &
vbCrLf
strMsg = strMsg & "Do you want to create a new Unit Plan?"
strMsg = strMsg & vbCrLf & vbCrLf & "Click Yes to create a New Unit Plan
or No to choose and existing one."
If MsgBox(strMsg, vbQuestion + vbYesNo, "Add new Unit Plan?") = vbNo Then
Response = acDataErrContinue
Else
Set db = CurrentDb
Set rs = db.OpenRecordset("Term Plans", dbOpenDynaset)
On Error Resume Next
rs.AddNew
rs![Term Plans] = NewData
rs.Update
If Err Then
MsgBox "An error occurred. Please try again."
Response = acDataErrContinue
Else
Response = acDataErrAdded
End If
End If
rs.Close
Set rs = Nothing
Set db = Nothing
End Sub
...only altering message dialogue and the database to "Plan Terms" (my db).
**Choosing Yes throws me straight to "An error occurred. Please try again."
without adding my new option to the list. Why does it ignore the first part
of the Else statement?
**Choosing No throws up run-time error 91, "Object variable or With block
variable not set" , the yellow debug highlight bar sits on "rs.Close" when
the code is opened via the bug message. Evidently this message has something
to do with incorrect setting of the variables?? Or Object libraries - I have
DAO 3.6 and ADO 2.1 selected - is this right?
Thanks.
PS Once again, I'm a complete beginner and don't really know what I'm talking
about ;-) - just trying to find solutions via the net.
BruceM wrote:
You could try putting the Response = ... line at the end of the section of
code (after inserting the new record, or after the undo). I'm not familiar
with using the NotInList exactly in the way you have done, but I have had
good success with code based on the following:
http://www.mvps.org/access/forms/frm0015.htm
Another approach is here:
http://www.datastrat.com/Code/NotInListCode.txt
I don't think SetWarnings will do anything to suppress the error messages.
Hi,[quoted text clipped - 47 lines]
Why do I still get the MS generic error messages?
--
Message posted via http://www.accessmonster.com
- Follow-Ups:
- Re: Combo "Not in List Event", MS generic message still appears
- From: MikeJohnB
- Re: Combo "Not in List Event", MS generic message still appears
- References:
- Re: Combo "Not in List Event", MS generic message still appears
- From: basiltabethacat via AccessMonster.com
- Re: Combo "Not in List Event", MS generic message still appears
- Prev by Date: How to change the defalt color of lines, arrows ect in "Drawing"?
- Next by Date: Re: Combo "Not in List Event", MS generic message still appears
- Previous by thread: Re: Combo "Not in List Event", MS generic message still appears
- Next by thread: Re: Combo "Not in List Event", MS generic message still appears
- Index(es):
Relevant Pages
|