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.

help: event happening when its not supposed to

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
reservedbcreater - 27 Jan 2005 20:22 GMT
i need to change my code so that the
Private Sub Command75_Click()
event doesnt happen unles the user chose "yes"
when prompted to save record, because then they choose cancel or no to not
save the code and i need it to stay on the current form, the
Command75_click() closes the current form and opens the enxt one.

here is my current code:

Private Sub Form_Load()

Dim strNextNumber As String

strNextNumber = Nz(DMax("ID", "General Housing Survey"), 0) + 1
Me.ID = strNextNumber

End Sub
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
Private Sub Command75_Click()
On Error GoTo Err_Command75_Click

Dim strDocName As String
Dim strID As String

If intresponseall = yes Then
strDocName = "Water"
strID = Me.ID
DoCmd.Close
DoCmd.OpenForm strDocName
Forms(strDocName)!ID = strID
End If

   
Exit_Command75_Click:
   Exit Sub

Err_Command75_Click:
   MsgBox Err.Description
   Resume Exit_Command75_Click
   
     
   
End Sub
reservedbcreater - 27 Jan 2005 21:05 GMT
i got it working but i get an error message, when i choose to not save the
record and then close the survey....it reads.....ms access cannot find the
form "water" referred to in a macro expression or visual basic code. but
what i want to happen works, its just i get that message.

here is my code:

Option Compare Database
Private Sub Form_Load()

Dim strNextNumber As String

strNextNumber = Nz(DMax("ID", "General Housing Survey"), 0) + 1
Me.ID = strNextNumber

End Sub
Private Sub Form_BeforeUpdate(Cancel As Integer)

Dim strDocName1 As String
Dim intResponse As Integer
strDocName1 = "Water"

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

Select Case intResponse
 Case vbYes
   intResponse2 = MsgBox("Go to next page", vbYesNo)
   Select Case intResponse2
   Case vbYes
   DoCmd.OpenForm strDocName1
   End Select
 Case vbNo
   Me.Undo  'To undo the edit
 Case vbCancel
   Cancel = True  'To cancel the update & hence the close
End Select

End Sub
Private Sub Command75_Click()
On Error GoTo Err_Command75_Click

Dim strDocName As String
Dim strID As String

strDocName = "Water"
strID = Me.ID
DoCmd.Close

Forms(strDocName)!ID = strID

   
Exit_Command75_Click:
   Exit Sub

Err_Command75_Click:
   MsgBox Err.Description
   Resume Exit_Command75_Click
   

 
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.