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 Programming / January 2005

Tip: Looking for answers? Try searching our database.

dont save a form's fields until a button is clicked

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
reservedbcreater - 27 Jan 2005 19:43 GMT
is there a way i can make it so they can fill out a form but it doesnt save
it to the table until they click the next button to go to next form of the
survey?????

i want this because if i was just to show someone the form(ie open it, i
coded it to assign an ID # to ID field upon opening). and then after
showing the person the form, just closed it, it would still save a record
in the table with the newly assigned ID# and all the other fields blank.
reservedbcreater - 27 Jan 2005 20:25 GMT
i fixed this with
Private Sub Form_BeforeUpdate(Cancel As Integer)

Dim intResponse As Integer

intResponse = MsgBox("Save Record?", vbYesNoCancel)

Select Case intResponse
 Case vbYes
   'Do Nothing
 Case vbNo
   Me.Undo  'To undo the edit
 Case vbCancel
   Cancel = True  'To cancel the update & hence the close
End Select

End Sub
John Vinson - 27 Jan 2005 21:36 GMT
>is there a way i can make it so they can fill out a form but it doesnt save
>it to the table until they click the next button to go to next form of the
[quoted text clipped - 4 lines]
>showing the person the form, just closed it, it would still save a record
>in the table with the newly assigned ID# and all the other fields blank.

You can put code in the Form's BeforeUpdate event to check to see if
it's valid to save. For instance you could put a statement

Dim bOkToClose As Boolean

before the first Sub in the Form's module; set this variable to False
in the form's Current event, and to True in the click event of your
"save" button. Then in the Form's BeforeUpdate event put something
like

Private Sub Form_BeforeUpdate(Cancel as Integer)
Dim iAns As Integer
If Not bOkToClose Then
  iAns = MsgBox("Please use the Save button, or select " _
     & " Cancel to erase this screen", vbOKCancel)
  Cancel = True
  If iAns = vbCancel Then
     Me.Undo
  End If
End If
End Sub

                 John W. Vinson[MVP]    
 
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.