Welcome to dbForumz.com!
FAQFAQ    SearchSearch      ProfileProfile    Private MessagesPrivate Messages   Log inLog in

problem setting "RecordSource" in Office Access 2007 ...

 
   Database Forums (Home) -> Visual Basic -> DAO RSS
Next:  include statement  
Author Message
Russell Potter

External


Since: Jun 10, 2007
Posts: 6



(Msg. 1) Posted: Thu Jul 05, 2007 11:55 pm
Post subject: problem setting "RecordSource" in Office Access 2007 ...
Archived from groups: microsoft>public>vb>database>dao (more info?)

I have a form in Office Access 2007, the "RecordSource"
property of which I;m trying to set.

But first, I some background: have a push button
control at the top of each column in my "overview"
form that, when pressed, is supposed to change the
sort order of the rows in the form to one based on
the values in that button's associated column (I
know there are form properties like "Filter",
"FilterOn", "OrderBy" and "OrderByOn" - none of
which I know anything about - that are probably
much easier to use and more appropriate for that
job than "RecordSource", but I wrote the application
using Access 2000, before - as far as I know - any
of those properties existed)

... Trouble is (in Office Access 2007, at least:
the problem doesn't appear in Access 2000), whenever I
click on any of those above-mentioned "sort" push
buttons, all the rows of the form (bar one) disappear,
and further presses of "sort" buttons keeps the rows
that way (although a subsequent close then reopen
the form, restores the original content, which
makes me think the rows are merely perhaps "hidden"
and not actually deleted)

Here's the troublesome routine I wrote called by
each button's "OnClick" procedure:

> ' "ChangeSort" - change the sort order of form
> ' "f", when button "cmdCol" is pressed, to that
> ' of the criteria of the form's underlying
> ' query named in the content of "strSQL".
> ' "strDesc" contains a description of the sort
> ' criteria
> Public Function ChangeSort(f As Form, _
> cmdCol As Control, _
> strDesc As String, _
> strSQL As String)
>
> Dim filter As String
> Dim i As Integer
>
> filter - Me!txtFilterSQL '"txtFilterSQL" is
> ' is a pre-existing
> ' hidden text box
> ' containing the
> ' SQL of the form's
> ' current filter
>
> For i = 0 To f.Count - 1
> ' all controls on the form are prefixed with
> ' a three-letter code indicating their types -
> ' so we assume, here, that push buttons (which
> ' are prefixed with "cmd") are "sort" buttons,
> ' and that the just-pressed button (the caption
> ' of which is set to "bold" to indicate the
> ' current sort order) is the "Active" control
> ' when thid routine id called the form (I've
> ' verified that this part of the code works
> ' fine)
>
> If Left(f(i).name, 3) = "cmd" Then
> f(i).FontBold = f(i).name = f. _
> ActiveControl.name
> End If
> Next
>
>
> ' set the firm's "RecordSource", bsded on the
> ' underlying query (which has the same name as
> ' the form, but with the form's prefix
> ' replaced by "qry")
> f.RecordSource = "SELECT * FROM qry" & _
> Mid(me.name, 4) & _
> " " filter & " ORDER BY _
> " & strSQL
> f.Requery
>
> End Function

Would anyone be able to tell me what I'm doing
wrong, how I might be implement this code
correctly and, if the problem is due to my
not using the "Filter" (and friends) properties,
how these properties should be properly used

thanks,
Russell

 >> Stay informed about: problem setting ""RecordSource"" in Office Access 2007 ... 
Back to top
Login to vote
Display posts from previous:   
   Database Forums (Home) -> Visual Basic -> DAO All times are: Pacific Time (US & Canada)
Page 1 of 1

 
You can post new topics in this forum
You can reply to topics in this forum
You can edit your posts in this forum
You can delete your posts in this forum
You can vote in polls in this forum



[ Contact us | Terms of Service/Privacy Policy ]