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 / Modules / DAO / VBA / February 2005

Tip: Looking for answers? Try searching our database.

DoCmd.OpenForm

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Jacco - 22 Feb 2005 08:05 GMT
This subject is abundant if typed in Google, but I keep getting a mistake,

I have created a Form Called "Edit Aircraft". I want this form to be opened
by another form. I inserted the Sample code found in the help-file:

Private Sub Form_Open(Cancel As Integer)
   Dim intReturn As Integer
   intReturn = MsgBox("Do you want to configure your aircraft now?",
vbYesNo)
   Select Case intReturn
       Case vbYes
           ' Open Order Details form.
           DoCmd.OpenForm "Edit Aircraft"
       Case vbNo
           MsgBox "Remember to configure this aircraft at a later time"
           Cancel = True                    ' Cancel Open event.
   End Select
End Sub

This triggers a error when the form is being opened saying:

Procedure declaration does not match description event or procedure having
the same name.

I set the property for Form On Open [event procedure]

I don't understand what the problem is. I created a new Form "Form1" and
inserted the identical OnOpen event (with "Form1 offcourse", and it works as
advertised.

Anyone knows where the problem is?

Jacco

my complete code for "Edit Aircraft" is:

Option Compare Database
Private Sub Form_Open(Cancel As Integer)
   Dim intReturn As Integer
   intReturn = MsgBox("Enter order details now?", vbYesNo)
   Select Case intReturn
       Case vbYes
           ' Open Order Details form.
           DoCmd.OpenForm "Edit Aircraft"
       Case vbNo
           MsgBox "Remember to enter order details by 5 P.M."
           Cancel = True                    ' Cancel Open event.
   End Select
End Sub

Private Sub List28_BeforeUpdate()
   Dim rs As Object
   Set rs = Me.Recordset.Clone
   rs.FindFirst "[Type] = '" & Me![List28] & "'"
   If Not rs.EOF Then Me.Bookmark = rs.Bookmark
End Sub

Private Sub List28_AfterUpdate()
   Dim rs As Object
   Set rs = Me.Recordset.Clone
   rs.FindFirst "[Type] = '" & Me![List28] & "'"
   If Not rs.EOF Then Me.Bookmark = rs.Bookmark
End Sub

Private Sub addnewaircraft_Click()
On Error GoTo Err_addnewaircraft_Click

   DoCmd.GoToRecord , , acNewRec

Exit_addnewaircraft_Click:
   Exit Sub

Err_addnewaircraft_Click:
   MsgBox Err.Description
   Resume Exit_addnewaircraft_Click

End Sub

Private Sub deletecurrentaircraft_Click()
On Error GoTo Err_deletecurrentaircraft_Click

   DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
   DoCmd.DoMenuItem acFormBar, acEditMenu, 6, , acMenuVer70

Exit_deletecurrentaircraft_Click:
   DoCmd.DoMenuItem acFormBar, acRecordsMenu, 5, , acMenuVer70
   Exit Sub

Err_deletecurrentaircraft_Click:
   MsgBox Err.Description
   Resume Exit_deletecurrentaircraft_Click

End Sub
Private Sub refreshaircraft_Click()
On Error GoTo Err_refreshaircraft_Click

   DoCmd.DoMenuItem acFormBar, acRecordsMenu, 5, , acMenuVer70

Exit_refreshaircraft_Click:
   Exit Sub

Err_refreshaircraft_Click:
   MsgBox Err.Description
   Resume Exit_refreshaircraft_Click

End Sub
Private Sub undochanges_Click()
On Error GoTo Err_undochanges_Click

   DoCmd.DoMenuItem acFormBar, acEditMenu, acUndo, , acMenuVer70
   DoCmd.DoMenuItem acFormBar, acRecordsMenu, 5, , acMenuVer70

Exit_undochanges_Click:
   Exit Sub

Err_undochanges_Click:
   MsgBox Err.Description
   Resume Exit_undochanges_Click

End Sub
Mike - 22 Feb 2005 11:11 GMT
You may wish to try this code instead of your current stuff. It may be a
sloppy way to do it but it'll work

On Error GoTo err_OpenAircraftForm

If MsgBox("Do you want to configure your aircraft now?", vbYesNo,
"EditAircraft") = vbYes Then
DoCmd.OpenForm "EditAircraft"
Else
GoTo err_CancelOpenAircraftForm
End If

err_OpenAircraftForm:
MsgBox Err.Description
GoTo err_CancelOpenAircraftForm

err_CancelOpenAircraftForm:
Exit Sub
End If

> This subject is abundant if typed in Google, but I keep getting a mistake,
>
[quoted text clipped - 116 lines]
>
> End Sub
Tim Ferguson - 22 Feb 2005 18:00 GMT
> Else
> GoTo err_CancelOpenAircraftForm
[quoted text clipped - 7 lines]
> Exit Sub
> End If

It's good to be reminded every so often why GoTo is such an evil
statement... <g>

All the best

Tim F
 
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.