Senin, 08 April 2013

Re: [AccessDevelopers] Re: Select Case statement for a list box fails

 

So this is what I have so far and I have stepped into the code and it always bypasses the Debug line. I think that the biggest issue is that I do not understand the select case statement. 

Jim Wagner

Private Sub cmdShowExample_Click()

If Not IsNull(Me![strObjectName]) Then


    Select Case Me![intObjectType]
           
        Case 1
        'Print Me![strObjectName]
            'DoCmd.OpenQuery Me![strObjectName], acViewDesign
         Debug.Print Me![intObjectType]
        Case 2
        'Print Me![strObjectName]
            'DoCmd.OpenForm Me![strObjectName], acPreview
      Debug.Print Me![intObjectType]
        Case 3
        'Print Me![strObjectName]
            'DoCmd.OpenReport Me![strObjectName], acViewDesign
         Debug.Print Me![intObjectType]
    End Select

Else
    MsgBox "No Name in table"
End If


    
End Sub

 
Jim Wagner


From: T. Hoffman <tobihoffman@comcast.net>
To: AccessDevelopers@yahoogroups.com
Sent: Friday, April 5, 2013 7:33 PM
Subject: RE: [AccessDevelopers] Re: Select Case statement for a list box fails

 
True – and maybe it actually should be
 
Debug.Print Me![intObjectType]
 
since that is what the Select Case statement is using!
 
Tobi
 
From: AccessDevelopers@yahoogroups.com [mailto:AccessDevelopers@yahoogroups.com] On Behalf Of Duane Hookom
Sent: Friday, April 05, 2013 6:12 PM
To: accessdevelopers@yahoogroups.com
Subject: RE: [AccessDevelopers] Re: Select Case statement for a list box fails
 
 
Should be

Debug.Print Me![strObjectName]

To: AccessDevelopers@yahoogroups.com
From: luvmymelody@yahoo.com
Date: Fri, 5 Apr 2013 14:52:36 -0700
Subject: Re: [AccessDevelopers] Re: Select Case statement for a list box fails

 
Tobi,
 
apparently there is no value. I stepped through the lines and it completely skips the docmd statements. I added the print line and still nothing. 
 
Jim Wagner

 

From: T. Hoffman <tobihoffman@comcast.net>
To: AccessDevelopers@yahoogroups.com
Sent: Friday, April 5, 2013 1:28 PM
Subject: RE: [AccessDevelopers] Re: Select Case statement for a list box fails
 
 
What I'm trying to suggest is that you need to know that you are passing a value to your Case statement, and it may be that it is not what you expect it should be.
 
Tobi
 
From: AccessDevelopers@yahoogroups.com [mailto:AccessDevelopers@yahoogroups.com] On Behalf Of Jim Wagner
Sent: Friday, April 05, 2013 3:48 PM
To: AccessDevelopers@yahoogroups.com
Subject: Re: [AccessDevelopers] Re: Select Case statement for a list box fails
 
 
Tobi
 
I added the Print Me![strObjectName] and I get the below error
 
Run-time error '438':
 
Object doesn't support this property or method
 
 
 
Jim Wagner

 

From: T. Hoffman <tobihoffman@comcast.net>
To: AccessDevelopers@yahoogroups.com
Sent: Friday, April 5, 2013 11:56 AM
Subject: RE: [AccessDevelopers] Re: Select Case statement for a list box fails
 
 
Add a line just before the Case statement:
 
Print Me![strObjectName]
 
And see what happens.  Or put a breakpoint in and trace through the code.
 
Tobi
 
From: AccessDevelopers@yahoogroups.com [mailto:AccessDevelopers@yahoogroups.com] On Behalf Of luvmymelody
Sent: Friday, April 05, 2013 1:54 PM
To: AccessDevelopers@yahoogroups.com
Subject: [AccessDevelopers] Re: Select Case statement for a list box fails
 
 
The tblTopicList has all the data in it, so I know that there is something to look at.

Jim

--- In AccessDevelopers@yahoogroups.com, "luvmymelody" <luvmymelody@...> wrote:
>
> Hello all,
>
> I have a form with a list box based on the database I found called QrySampl. This db has a list box on it and a user chooses from the list box or dbl click the item and the query opens up in design view. I am trying to replicate the form and it bypasses the case statements and nothing happens. I am not sure what is missing here. It seems so straight forward. Below is the code on the button to open the object. I must be missing something. strObjectName and intObjectType are fields in the tblTopicList table.
>
> Thank You for any help on this.
>
> Jim Wagner
>
> Private Sub cmdShowExample_Click()
>
> If Not IsNull(Me![strObjectName]) Then
>
> Select Case Me![intObjectType]
>
> Case 1
> DoCmd.OpenQuery Me![strObjectName], acViewDesign
>
> Case 2
> DoCmd.OpenForm Me![strObjectName], acPreview
>
> Case 3
> DoCmd.OpenReport Me![strObjectName], acViewDesign
>
> End Select
>
> Else
> MsgBox "No Name in table"
> End If
>
>
> End Sub
>
 
 
 


__._,_.___
Reply via web post Reply to sender Reply to group Start a New Topic Messages in this topic (9)
Recent Activity:

Please zip all files prior to uploading to Files section.
.

__,_._,___

Tidak ada komentar:

Posting Komentar