Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Forms / November 2007

Tip: Looking for answers? Try searching our database.

Not in the List Code Question

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
scott04 - 30 Nov 2007 15:19 GMT
Hi everyone, I am using the following code in the event an item isn't in my
list:
Private Sub Plaintiff_s_Firm_NotInList(NewData As String, Response As Integer)
Dim strSQL As String
   Dim i As Integer
   Dim Msg As String
   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, "Would you like to add a new
plaintiff's firm name?...")
   If i = vbYes Then
       strSQL = "Insert Into tblplaintiffs_firm_name
([Plaintiffs_firm_name]) " & _
                "values ('" & NewData & "');"
       CurrentDb.Execute strSQL, dbFailOnError
       Response = acDataErrAdded
   Else
       Response = acDataErrContinue
   End If

If I enter something that is not in the list it prompts me whether I want to
add it.  If i select yes that i want to add it and hit ok, the code does work
and it does add it to the list.  My only problem is that once i hit ok to add
it to the list, my next record "pops up".  Is there something I can place in
my code such that if i hit ok to add it to the list that it stays in the
current record?  Any help is appreciated.
scott04 - 30 Nov 2007 15:26 GMT
This only happens to go to the next record for example if i have to go back
into the form and change this field.  If i enter it on a new record for
example there is no problems with the code.
Roger Carlson - 30 Nov 2007 15:56 GMT
Try setting the Cycle property of the form to "Current Record".

Signature

--Roger Carlson
 MS Access MVP
 Access Database Samples: www.rogersaccesslibrary.com
 Want answers to your Access questions in your Email?
 Free subscription:
 http://peach.ease.lsoft.com/scripts/wa.exe?SUBED1=ACCESS-L

> This only happens to go to the next record for example if i have to go
> back
> into the form and change this field.  If i enter it on a new record for
> example there is no problems with the code.
scott04 - 30 Nov 2007 16:19 GMT
Roger,
Thank you.  It works perfectly now.

> Try setting the Cycle property of the form to "Current Record".
>
> > This only happens to go to the next record for example if i have to go
> > back
> > into the form and change this field.  If i enter it on a new record for
> > example there is no problems with the code.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.