Senin, 08 April 2013

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

Jim,
Place a breakpoint at the line beginning "If Not..." I expect strObjectName has no value and the code never gets to the Select Case lines. 

What is strObjectName? Is this a bound text box or what?

Duane Hookom MVP
MS Access
________________________________
> From: luvmymelody@yahoo.com 

>
> 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<mailto:AccessDevelopers@yahoogroups.com>
> From: luvmymelody@yahoo.com<mailto: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<mailto:tobihoffman@comcast.net>>
> To: AccessDevelopers@yahoogroups.com<mailto: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>
> [mailto:AccessDevelopers@yahoogroups.com] On Behalf Of Jim Wagner
> Sent: Friday, April 05, 2013 3:48 PM
> To: AccessDevelopers@yahoogroups.com<mailto: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<mailto:tobihoffman@comcast.net>>
> To: AccessDevelopers@yahoogroups.com<mailto: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>
> [mailto:AccessDevelopers@yahoogroups.com] On Behalf Of luvmymelody
> Sent: Friday, April 05, 2013 1:54 PM
> To: AccessDevelopers@yahoogroups.com<mailto: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<mailto:AccessDevelopers%40yahoogroups.com>,
> "luvmymelody" <luvmymelody@...<mailto: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
> >
>
>
>
>
>
>
>

------------------------------------


Please zip all files prior to uploading to Files section.Yahoo! Groups Links

<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/AccessDevelopers/

<*> Your email settings:
Individual Email | Traditional

<*> To change settings online go to:
http://groups.yahoo.com/group/AccessDevelopers/join
(Yahoo! ID required)

<*> To change settings via email:
AccessDevelopers-digest@yahoogroups.com
AccessDevelopers-fullfeatured@yahoogroups.com

<*> To unsubscribe from this group, send an email to:
AccessDevelopers-unsubscribe@yahoogroups.com

<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/

Tidak ada komentar:

Posting Komentar