PC Review


Reply
Thread Tools Rate Thread

DoCmd.OpenForm

 
 
Jacco
Guest
Posts: n/a
 
      22nd Feb 2005
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



 
Reply With Quote
 
 
 
 
=?Utf-8?B?TWlrZQ==?=
Guest
Posts: n/a
 
      22nd Feb 2005
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

"Jacco" wrote:

> 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
>
>
>
>

 
Reply With Quote
 
Tim Ferguson
Guest
Posts: n/a
 
      22nd Feb 2005
"=?Utf-8?B?TWlrZQ==?=" <(E-Mail Removed)> wrote in
news:FB4B85E5-3750-42CE-BB5A-(E-Mail Removed):

> Else
> GoTo err_CancelOpenAircraftForm
> End If
>
> err_OpenAircraftForm:
> MsgBox Err.Description
> GoTo err_CancelOpenAircraftForm
>
> err_CancelOpenAircraftForm:
> 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

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
docmd.openform tg112001 via AccessMonster.com Microsoft Access Forms 6 11th Jan 2008 04:00 AM
docmd.openform =?Utf-8?B?SGFycnk=?= Microsoft Access VBA Modules 2 16th Apr 2007 08:06 AM
DoCmd.OpenForm =?Utf-8?B?R3JlZw==?= Microsoft Access VBA Modules 4 24th Jun 2006 01:11 PM
DoCmd.OpenForm L.A. Lawyer Microsoft Access Form Coding 4 2nd Jan 2004 08:08 PM
Docmd.OpenForm Capn Ron Microsoft Access Form Coding 2 21st Oct 2003 06:10 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 03:52 PM.