SQL Scalar Valued function in VBA for a Access Project (ADP)

G

Guest

How do i use a SQL Server Scalar-valued function in MS Access ADP?

I have a function "fGrantAccess" in the SQL Server Database and i would like
to use it in an Access Project. The function returns a GUID from a table
depending on two parameters: user id and password.

I thought the function would operate in a similar fashion to a view or
table-valued function; however, i was mistaken.

This line's error is "Invalid Object Name"..

rdsStr = "SELECT fGrantAccess FROM dbo.fGrantAccess WHERE (" & _
"(uiLoginId='" & uName.Value & "') AND " & _
"(uiLoginPw='" & uPass.Value & "'));"

rdsADO.Open rdsStr, Application.CurrentProject.Connection,
adOpenForwardOnly, adLockReadOnly

ps. i have also tried setting the sql string to

rdsStr = "SELECT fGrantAccess FROM {fn {fGrantAccess('" & uName.Value &
"','" & uPass.Value & "')}};"

Thank you for your help...
 
R

RoyVidar

rogge said:
How do i use a SQL Server Scalar-valued function in MS Access ADP?

I have a function "fGrantAccess" in the SQL Server Database and i
would like to use it in an Access Project. The function returns a
GUID from a table depending on two parameters: user id and password.

I thought the function would operate in a similar fashion to a view
or table-valued function; however, i was mistaken.

This line's error is "Invalid Object Name"..

rdsStr = "SELECT fGrantAccess FROM dbo.fGrantAccess WHERE (" & _
"(uiLoginId='" & uName.Value & "') AND " & _
"(uiLoginPw='" & uPass.Value & "'));"

rdsADO.Open rdsStr, Application.CurrentProject.Connection,
adOpenForwardOnly, adLockReadOnly

ps. i have also tried setting the sql string to

rdsStr = "SELECT fGrantAccess FROM {fn {fGrantAccess('" & uName.Value
& "','" & uPass.Value & "')}};"

Thank you for your help...

Assuming username is the first parameter, and password the second, try
something like this:

rdsStr = "SELECT dbo.fGrantAccess('" & uName.Value & "', " & _
uPass.Value & "')"
 
G

Guest

Baz, that worked like a charm... i need to adjust the rest of my code; but,
hopefully, i will be able to figure that out... have a good week
 
G

Guest

Thanks Roy... it worked for me

RoyVidar said:
Assuming username is the first parameter, and password the second, try
something like this:

rdsStr = "SELECT dbo.fGrantAccess('" & uName.Value & "', " & _
uPass.Value & "')"
 

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