2007年10月10日水曜日

ユーザー定義関数をvbaで使うには

function sub で select句の中に組み込む

Function seireki(gen As Long) As Date
Dim cnn As ADODB.Connection
Dim rst As ADODB.Recordset
'Dim date1 As Date
Set rst = New ADODB.Recordset
strsql = "select dbo.fndateconv2(" & gen & ") as date1 "

Set cnn = CurrentProject.Connection
rst.Open strsql, cnn, adOpenForwardOnly, adLockReadOnly

seireki = rst!date1

rst.Close
Set rst = Nothing
Set cnn = Nothing
End Function

0 件のコメント:

コメントを投稿