Group:  Microsoft Access ยป microsoft.public.access.adp.sqlserver
Thread: Controls disappear when form's recordsource returns no records

DotNetBag
.NET Development Newsgroups

HTVi
TV Discussion Newsgroups

Our Hot Pick: Rising Antivirus 2006 - Certified by TUV & Checkmark! Get 10% discount by entering this coupon code: ONDISCOUNT10
Rising Antivirus 2006

Controls disappear when form's recordsource returns no records
"KC" <kcjunk69[ at ]hotmail.com> 28.09.2006 18:53:49
I have a form with two unbound combo boxes from which a user selects a
month and year of interest. The form also has textboxes whose control
sources are populated with the names of fields in my (as yet unrun)
stored procedure (actually it's a function). The form itself does not
have a recordsource defined.

There is also a command button on the form:

Private Sub Command4_Click()
Dim ldStrtDate As Date, ldEndDate As Date

Me.RecordSource = ""

Call GetDates(ldStrtDate, ldEndDate)

Me.InputParameters = "[ at ]StrtDate = '" + Format(ldStrtDate) +
"',[ at ]EndDate = '" + Format(ldEndDate) + "'"
Me.RecordSource = "fn_GetSumbyDate"

Me.Refresh
End Sub

Now, everthing works absolutely perfectly as long as the dates selected
by the user are valid (ie there are records in the tables that fall
within the specified dates). However, if the dates specified result in
no records being returned from the function, ALL FIELDS DISAPPEAR FROM
THE FORM.

Why?
How to fix?

Thanks in advance,
KC

Re: Controls disappear when form's recordsource returns no records
"Sylvain Lafontaine" <sylvain aei ca (fill the blanks, no spam please)> 28.09.2006 19:31:29
No result, no fields.

You could test for an empty recordset and unbound the form if the recordset
is empty; however, if there are nothing to display, why should you care?

You can also activate the possibility of Allowing Addtions for the form but
again, why care?

--
Sylvain Lafontaine, ing.
MVP - Technologies Virtual-PC
E-mail: http://cerbermail.com/?QugbLEWINF


"KC" <kcjunk69[ at ]hotmail.com> wrote in message
news:1159469629.011191.42620[ at ]b28g2000cwb.googlegroups.com...
[Quoted Text]
>I have a form with two unbound combo boxes from which a user selects a
> month and year of interest. The form also has textboxes whose control
> sources are populated with the names of fields in my (as yet unrun)
> stored procedure (actually it's a function). The form itself does not
> have a recordsource defined.
>
> There is also a command button on the form:
>
> Private Sub Command4_Click()
> Dim ldStrtDate As Date, ldEndDate As Date
>
> Me.RecordSource = ""
>
> Call GetDates(ldStrtDate, ldEndDate)
>
> Me.InputParameters = "[ at ]StrtDate = '" + Format(ldStrtDate) +
> "',[ at ]EndDate = '" + Format(ldEndDate) + "'"
> Me.RecordSource = "fn_GetSumbyDate"
>
> Me.Refresh
> End Sub
>
> Now, everthing works absolutely perfectly as long as the dates selected
> by the user are valid (ie there are records in the tables that fall
> within the specified dates). However, if the dates specified result in
> no records being returned from the function, ALL FIELDS DISAPPEAR FROM
> THE FORM.
>
> Why?
> How to fix?
>
> Thanks in advance,
> KC
>


Re: Controls disappear when form's recordsource returns no records
"Robert Morley" <rmorley[ at ]magma.ca.N0.Freak1n.sparn> 28.09.2006 20:39:29
I don't know if it would be appropriate for what you're trying to do, but
would it make sense to move things like the command button (Command4) to the
form header or form footer? Or am I misunderstanding the problem?



Rob

"KC" <kcjunk69[ at ]hotmail.com> wrote in message
news:1159469629.011191.42620[ at ]b28g2000cwb.googlegroups.com...
[Quoted Text]
>I have a form with two unbound combo boxes from which a user selects a
> month and year of interest. The form also has textboxes whose control
> sources are populated with the names of fields in my (as yet unrun)
> stored procedure (actually it's a function). The form itself does not
> have a recordsource defined.
>
> There is also a command button on the form:
>
> Private Sub Command4_Click()
> Dim ldStrtDate As Date, ldEndDate As Date
>
> Me.RecordSource = ""
>
> Call GetDates(ldStrtDate, ldEndDate)
>
> Me.InputParameters = "[ at ]StrtDate = '" + Format(ldStrtDate) +
> "',[ at ]EndDate = '" + Format(ldEndDate) + "'"
> Me.RecordSource = "fn_GetSumbyDate"
>
> Me.Refresh
> End Sub
>
> Now, everthing works absolutely perfectly as long as the dates selected
> by the user are valid (ie there are records in the tables that fall
> within the specified dates). However, if the dates specified result in
> no records being returned from the function, ALL FIELDS DISAPPEAR FROM
> THE FORM.
>
> Why?
> How to fix?
>
> Thanks in advance,
> KC
>


Home | Search | Terms | Imprint | Contact
Newsgroups Reader - provided by WiredBox.Net