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

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

 
   Database Help (Home) -> Visual Basic -> DAO RSS
Next:  is there any sql statement for ...  
Author Message
Russell Potter

External


Since: Jun 10, 2007
Posts: 1



(Msg. 1) Posted: Fri Jul 06, 2007 1:18 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:   
Related Topics:
DAO reference / Access 2007 - while using an Access 2007 .accdb file I can access the dao. object very easily. the following code in VBA works well : Function getrecordcount(strTableName As String) As Long Dim dbCurrent As DAO.Database Set db = CurrentDb Dim rstRecords A...

Problem with DAO (Import from Excel to Access)! :( - Hi, I am novice and I have problem. I need import some data with Excel file to Access. Problem introduces as follows: In Excel(first sheet) i have data: "TYTUL" - column "A" "NAZWISKO" - column "B" "IMIE&quot...

Error after converting from Access 97 to Access 2002-2003 .. - Hello, I convert my Access 97 Database to Access 2002-2003, because I’m now using WinXP. And now when I run my VB program, I get Runtime error '3343' - Unrecognized database format. I'm using DAO350.DLL. Do I have to change to another DLL? Thanks. ....

VB6 Access 2000 : Error 3085 undefined function, works wh.. - I've been using VB6 with DAO 3.6 and an Access 2000 format database fine for a few years. I recently added a module function that one of the Access queries uses. It is only called from with the Access query. When I try to set the first parameter from....

Password problem - Hey, I've been using ADO for a few years now and now I need to simply open an access DB using DAO3.6 which has is password protected. set dbtemp = opendatabase("MyDB.MDB",False,False," ;pwd=mypass") I get an error about "canno...
   Database Help (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 ]