recordsource

  • Thread starter Thread starter mcnewsxp
  • Start date Start date
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.
?
 
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?
 
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"
 
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.
 
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
 
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.
 
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.
 
m> instead of strRecordSource = "SELECT * FROM dbo.whatever...."
m> i need strRecordSource = "dbo.whatever"

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


Vadim Rapp
 
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.
 
Back
Top