recordsource

M

mcnewsxp

i need to store a forms recordsource in a variable.
when i use me.recordsource i get a SQL statement.
the form is bound to a table - not a stored proc or view.
?
 
P

PBsoft

i need to store a forms recordsource in a variable.

Ok.
when i use me.recordsource i get a SQL statement.
Right.

the form is bound to a table - not a stored proc or view.
Ok.

?

What's the matter?
 
M

mcnewsxp

i need to store a forms recordsource in a variable.
Ok.


What's the matter?

instead of strRecordSource = "SELECT * FROM dbo.whatever...."
i need strRecordSource = "dbo.whatever"
 
P

PBsoft

instead of strRecordSource = "SELECT * FROM dbo.whatever...." i need
strRecordSource = "dbo.whatever"

Sorry, but I continue to be confused.
Please, explain clearly what you have, what you want, what you did, what
you got.
 
R

Robert Morley

Instead of returning a record source of simply "dbo.MyTable", it's returning
"SELECT * FROM dbo.MyTable", which is not what he wants.

ncnewsxp: I'm not at work, so I can't test how this works in a SQL Server
environment, but I'm guessing you may simply have to parse the recordsource
you get back.



Rob
 
M

mcnewsxp

instead of strRecordSource = "SELECT * FROM dbo.whatever...." i need
Sorry, but I continue to be confused.
Please, explain clearly what you have, what you want, what you did, what
you got.

can't be much clearer....

i passed me.recordsoure as a parameter to a form from a form.

when i set my string variable to me.OpenArgs of the opened form the
recordsource is a SELECT query.
all i need is the table name.
 
M

mcnewsxp

Instead of returning a record source of simply "dbo.MyTable", it's
returning "SELECT * FROM dbo.MyTable", which is not what he wants.

ncnewsxp: I'm not at work, so I can't test how this works in a SQL Server
environment, but I'm guessing you may simply have to parse the
recordsource you get back.

i thought of that.
just wondering if there's a better way.
 
V

Vadim Rapp

m> instead of strRecordSource = "SELECT * FROM dbo.whatever...."
m> i need strRecordSource = "dbo.whatever"

yourvariable = split(strrecordsource,"SELECT * FROM ")(1)


Vadim Rapp
 
P

PBsoft

i thought of that.
just wondering if there's a better way.

As others already told you about the parsing method, you can also evalute
the possibility to change the recordsource of the form from

SELECT * FROM dbo.whatever

to

whatever

so then in the report you will uise the following code:

Me.Recordsource = Forms("yourformnamehere").Recordsource
Me.RecordSourceQualifier = Forms("yourformnamehere").RecordSourceQualifier

Obviously, this solution is not suitable for most cases, e.g. where the recordsource
is a more complex SQL statement. In that case, anyway, you can create a VIEW
or a STORED PROCEDURE with the original SQL statement and then use the same
procedure I described.

Bye.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top