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 / May 2008

Tip: Looking for answers? Try searching our database.

Want option of creating a new record without error messages.

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Billy Smith - 16 May 2008 18:27 GMT
I'm using Access 2000 and VBA.

I have a simple bound form that displays a set of records.  Sometimes,
when I am not interested in creating a new record, I scroll beyond
the last existing record, i.e. to  the "new" record.  When I immediately
try to scroll back to the previous record I get an error message
because it tries to save the "new" record it thinks I was trying
to create and of course some of the fields are null because I
didn't fill them in.

I want the option of creating a new record when I scroll to that
"new" record position (i.e. after the last existing record) but
I want to be able to just scroll back to the previous record without
error messages if I don't want to create a new record.  How can I do this?

I'm thinking I should put up a yes/no msg box when I scroll to the
"new" record position.  I've tried checking for current record in
the form's BeforeUpdate event routine, the Current event routine,
using the Undo method on the form and moving to the previous record
but still can't get it to do just what I want.

Any Ideas on how I can do this?

Thanks in advance.
Billy Smith - 17 May 2008 03:29 GMT
Just in case it helps someone else, here's a solution I came up with.  This
combination of event procedures lets the user say whether he wants to create
a new record, do it if he wants, and scroll back to a previous record if he
does not.

Private bolCreatingNewRecord As Boolean

Private Sub Form­_Current
Dim intReturn As Integer
   If Me.NewRecord Then
       intReturn = MsgBox("Want to create new Task?", vbYesNo)
       If intReturn = vbYes Then
           bolCreatingNewRecord = True
       Else
           bolCreatingNewRecord = False
       End If
   End If
End Sub

Private Sub Form_BeforeUpdate
   If Me.NewRecord Then
       If Not bolCreatingNewRecord Then
           Me.Undo
       End If
   End If
End Sub

> I'm using Access 2000 and VBA.
>
[quoted text clipped - 20 lines]
>
> Thanks in advance.
Jason - 18 May 2008 03:47 GMT
Not sure what the problem is - I quite often scroll to the new record and
back. Without entering anything inthe new record you should just be able to
go back. However, if you have started entering in the record (you didn't
specify) then this error would occur if fields data is not valid for that
particular field.

> I'm using Access 2000 and VBA.
>
[quoted text clipped - 20 lines]
>
> Thanks in advance.
 
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.