Rabu, 25 Juli 2012

Re: [MS_AccessPros] Do not display a form if the control source (a query) return no rows

 

I just tried this code and it worked

If DCount("*", "[tblTaskDetails]") = 0 Then
sfrmTaskDetails.Visible = False
MsgBox "sorry"
Else

Cancel = True
End If
 
Jim Wagner
________________________________

________________________________
From: Jim Wagner <luvmymelody@yahoo.com>
To: "MS_Access_Professionals@yahoogroups.com" <MS_Access_Professionals@yahoogroups.com>
Sent: Wednesday, July 25, 2012 12:06 PM
Subject: Re: [MS_AccessPros] Do not display a form if the control source (a query) return no rows


 
Thomas

Maybe on the onload event of the main form you can try you new code but tell the subform to be visible if there is data

If SubformName.RecordSet.RecordCount = 0 Then
SubformName.visible = true
Else
 MsgBox "Sorry but there are no records to display!"
 Cancel = True
 End If 

 
Jim Wagner
________________________________

________________________________
From: Thomas <thomas_lam_us@yahoo.com>
To: MS_Access_Professionals@yahoogroups.com
Sent: Wednesday, July 25, 2012 11:44 AM
Subject: Re: [MS_AccessPros] Do not display a form if the control source (a query) return no rows

 
Thank you Gentlemen

Now I have another challenge.

What if the form is a subform? I understand there is OnChange event using the TabControl. How do you suppress the display of the form?

Regards,
Thomas
--- In MS_Access_Professionals@yahoogroups.com, Jim Wagner <luvmymelody@...> wrote:
>
> Robert 
>
> I like that better. 
>
> Thank You
>  
> Jim Wagner
> ________________________________
>
>
>
> ________________________________
> From: Robert Peterson <bob@...>
> To: MS_Access_Professionals@yahoogroups.com
> Sent: Wednesday, July 25, 2012 10:52 AM
> Subject: RE: [MS_AccessPros] Do not display a form if the control source (a query) return no rows
>
>
>  
> I think this is pretty quick and easy
>
> If Me.RecordSet.RecordCount = 0 Then
> MsgBox "Sorry but there are no records to display!"
> Cancel = True
> End If
>
> Bob Peterson
>
> -----Original Message-----
> From: MS_Access_Professionals@yahoogroups.com [mailto:MS_Access_Professionals@yahoogroups.com] On Behalf Of Thomas
> Sent: Wednesday, July 25, 2012 1:17 PM
> To: MS_Access_Professionals@yahoogroups.com
> Subject: Re: [MS_AccessPros] Do not display a form if the control source (a query) return no rows
>
> Hi Crystal,
>
> So I still have to check if there is something to be displayed on the form and then do something.
>
> There is no quick and easy way of checking if zero row is return or something like that.
>
> Regards,
> Thomas
>
> --- In MS_Access_Professionals@yahoogroups.com, Crystal <strive4peace2008@> wrote:
> >
> > Hi Thomas,
> >
> > the Form OPEN Event has Cancel
> >
> > Warm Regards,
> > Crystal
> >
> > Learn Access on YouTube
> > http://www.YouTube.com/LearnAccessByCrystal
> >
> >
> >  *
> >    (: have an awesome day :)
> >  *
> >
> >
> >
> > ________________________________
> > From: Thomas <thomas_lam_us@>
> > To: MS_Access_Professionals@yahoogroups.com
> > Sent: Tuesday, July 24, 2012 5:40 PM
> > Subject: [MS_AccessPros] Do not display a form if the control source (a query) return no rows
> >
> > What is the event which will be fired under this condition? Can I display a message box and then issue the CANCEL = TRUE to suppress the form from displaying?
> >
> > Regards,
> > Thomas
> >
> >
> >
> >
> >
> > ------------------------------------
> >
> > Yahoo! Groups Links
> >
> >
> >
> > [Non-text portions of this message have been removed]
> >
>
> ------------------------------------
>
> Yahoo! Groups Links
>
>
>
>
> [Non-text portions of this message have been removed]
>

[Non-text portions of this message have been removed]

[Non-text portions of this message have been removed]

__._,_.___
Recent Activity:
.

__,_._,___

Tidak ada komentar:

Posting Komentar