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 / August 2005

Tip: Looking for answers? Try searching our database.

Run Time Error - dn't understand why it's bombing

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Pamela - 02 Aug 2005 19:49 GMT
Hello,

I have a case statement which is bombing at runtime.  The statement is as
follows:

Case 2  'goto Routing details tab

   If (CurrentRecord > Recordset.RecordCount) And (IsNull(Forms.
frmCorrespondence.ID)) Then   'adding new record
       MsgBox "Must Enter Correspondence Information First!", vbExclamation,
"Required Information"  'force entry on first page
       frmControls.Value = 1
       DoCmd.GoToPage 1
       Forms.frmCorrespondence.ID.SetFocus
       'Go back to Correspondence info page
   ElseIf Forms.sfrmTaskAudit.chkOther = -1 And ((IsNull(Forms.sfrmTaskAudit.
Comments)) Or (Forms.sfrmTaskAudit.Comments = "")) Then
       DoCmd.Beep
       ' Comment required
       MsgBox "Comment Required!  Please Enter A Comment.", vbExclamation,
"Other Change Entered"
       Forms.sfrmTaskAudit.chkEPDB.SetFocus
       Forms.sfrmTaskAudit.Comments.SetFocus
       ' Force comment in comment field if Other is selected
       frmControls.Value = 3
   Else
       DoCmd.GoToPage 2  'allow navigation to Page 2
   End If

The statement the debugger higlights is the following:

   ElseIf Forms.sfrmTaskAudit.chkOther = -1 And ((IsNull(Forms.sfrmTaskAudit.
Comments)) Or (Forms.sfrmTaskAudit.Comments = "")) Then

The message received is:  

Runtime Error '438'
Object doesn't support this property or method.  

I don't understand why this bombs but
   If (CurrentRecord > Recordset.RecordCount) And (IsNull(Forms.
frmCorrespondence.ID)) Then  
works fine (it worked before I added the above code that's bombing).

Does it have something to do with the ElseIf ?  Any help would be appreciated.

Thanks!

-Pamela
Chaim - 02 Aug 2005 20:37 GMT
Is 'sfrmTaskAudit' a subform? If so, you need to add a layer to the reference:

Forms!<Name of the form>!sfrmTaskAudit.Comments

Good Luck!
Signature

Chaim

> Hello,
>
[quoted text clipped - 45 lines]
>
> -Pamela
Pamela - 03 Aug 2005 11:47 GMT
Yes, it is a subform, but it's name is "sfrmTaskAudit".  "Comments" is a
control on the subform, and frmControls is a group of toggle buttons which
control navigation between the forms.  I have since changed the code to use
Case statements instead.  What I am trying to do is to prevent the user from
navigating away from the subform if they have not filled in required
information on the subform once a check box is selected.  Here is the entire
code for the sub in more readable format:

Private Sub frmControls_Click()

Select Case frmControls
Case 1 ' goto correspondence details tab
      If (Forms.sfrmTaskAudit.chkOther = -1) And ((IsNull(Forms.
sfrmTaskAudit.Comments)) Or (Forms.sfrmTaskAudit.Comments = "")) Then
        DoCmd.Beep
        'Comment required on Changes Details tab
         MsgBox "Comment Required!  Please Enter A Comment.", vbExclamation,
"Other Change Entered"
        Forms.sfrmTaskAudit.chkEPDB.SetFocus
        Forms.sfrmTaskAudit.Comments.SetFocus
       'Force comment in comment field if Other is selected
        frmControls.Value = 3
       Else
        DoCmd.GoToPage 1  'allow navigation away
       End If
Case 2  'goto Routing details tab

   If (CurrentRecord > Recordset.RecordCount) And (IsNull(Forms.
frmCorrespondence.ID)) Then   'adding new record
       MsgBox "Must Enter Correspondence Information First!", vbExclamation,
"Required Information"  'force entry on first page
       frmControls.Value = 1
       DoCmd.GoToPage 1
       Forms.frmCorrespondence.ID.SetFocus
       'Go back to Correspondence info page
   ElseIf Forms.sfrmTaskAudit.chkOther = -1 And ((IsNull(Forms.sfrmTaskAudit.
Comments)) Or (Forms.sfrmTaskAudit.Comments = "")) Then
       DoCmd.Beep
       ' Comment required
       MsgBox "Comment Required!  Please Enter A Comment.", vbExclamation,
"Other Change Entered"
       Forms.sfrmTaskAudit.chkEPDB.SetFocus
       Forms.sfrmTaskAudit.Comments.SetFocus
       ' Force comment in comment field if Other is selected
       frmControls.Value = 3
   Else
       DoCmd.GoToPage 2  'allow navigation to Page 2
   End If
   
Case 3  'Goto Changes Details form

    If (CurrentRecord > Recordset.RecordCount) And (IsNull(Forms.
frmCorrespondence.ID)) Then   'adding new record
       MsgBox "Must Enter Correspondence Information First!", vbExclamation,
"Required Information"  'force entry on first page
       frmControls.Value = 1
       Forms.frmCorrespondence.ID.SetFocus
       'DoCmd.GoToPage 1  'Go back to Correspondence info page
    Else
       DoCmd.GoToPage 4
    End If
   
Case 4  'Goto Provider Details form

    If (Forms.sfrmTaskAudit.chkOther = -1) And ((IsNull(Forms.sfrmTaskAudit.
Comments)) Or (Forms.sfrmTaskAudit.Comments = "")) Then
       DoCmd.Beep
       ' Comment Required
       MsgBox "Comment Required!  Please Enter A Comment.", vbExclamation,
"Other Change Entered"
       Forms.sfrmTaskAudit.chkEPDB.SetFocus
       Forms.sfrmTaskAudit.Comments.SetFocus
       ' Force comment in comment field if Other is selected
       frmControls.Value = 3
    Else
       DoCmd.GoToPage 3  'Allow navigation to provider info page
    End If
End Select
End Sub

It doesn't like this:

    If (Forms.sfrmTaskAudit.chkOther = -1) And ((IsNull(Forms.sfrmTaskAudit.
Comments)) Or (Forms.sfrmTaskAudit.Comments = ""))

Is "Forms.sfrmTaskAudit.chkOther"  not the correct way to reference a control
on a subform?  Maybe you're saying I need the name of the form the subform
lives on in there too?

I tried:  ElseIf Forms.frmCorrespondence.sfrmTaskAudit.chkOther = -1 And (
(IsNull(Forms.frmCorrespondence.sfrmTaskAudit.Comments)) Or (Forms.
frmCorrespondence.sfrmTaskAudit.Comments = "")) Then

And it bombs too (frmCorrespondence is the main form, sfrmTaskAudit the
subform, chkOther the check box on the sub form).   Seems to not like the
ElseIf?

I guess my question should be how to reference a control on a subform...
apparently I'm not doing it right.

Thanks!

>Is 'sfrmTaskAudit' a subform? If so, you need to add a layer to the reference:
>
[quoted text clipped - 6 lines]
>>
>> -Pamela
Pamela - 03 Aug 2005 12:41 GMT
Thanks for steering me in the right direction.  :)  I found this:

Referencing forms can be a bit tricky.  The following statement shows the
general syntax that you should be using:

=[forms]![MyMainForm]![MySubForm].Form!MyControlNameOnSubForm

Please note that the important part is the period  . between [MySubForm] and
Form

Now I just need to clean up my logic.  :-P

-Pamela

>Yes, it is a subform, but it's name is "sfrmTaskAudit".  "Comments" is a
>control on the subform, and frmControls is a group of toggle buttons which
[quoted text clipped - 103 lines]
>>>
>>> -Pamela
 
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.