Function for Record Set

G

Greg

I'm trying to write a function in a module, which I can use in several forms
to set the Rowsource of a combo box as follows

Public Function Sections_by_Type(Structural_Type_ID As String, Grade As
Double)
Sections_by_Type = "SELECT [Structural Sizes].Section_ID, [Structural
Sizes].SIZE, [Structural Sizes].Structural_Type_ID " & _
"FROM [Structural Sizes] WHERE ((([Structural Sizes].Structural_Type_ID)= '"
& Structural_Type_ID & "' AND ([Structural Sizes].GRADE)= '" & Grade & "' ));"
End Function

with the form code containing

Section_ID.Rowsource = Sections_by_Type(Me.Structural_Type_ID.Text,
Me.Structural_Grade.Value)

This function doesn't seem to work, if anyone can help I'd greatly
appreciate it.
 
D

Dirk Goldgar

Greg said:
I'm trying to write a function in a module, which I can use in several
forms
to set the Rowsource of a combo box as follows

Public Function Sections_by_Type(Structural_Type_ID As String, Grade As
Double)
Sections_by_Type = "SELECT [Structural Sizes].Section_ID, [Structural
Sizes].SIZE, [Structural Sizes].Structural_Type_ID " & _
"FROM [Structural Sizes] WHERE ((([Structural Sizes].Structural_Type_ID)=
'"
& Structural_Type_ID & "' AND ([Structural Sizes].GRADE)= '" & Grade &
"' ));"
End Function

with the form code containing

Section_ID.Rowsource = Sections_by_Type(Me.Structural_Type_ID.Text,
Me.Structural_Grade.Value)

This function doesn't seem to work, if anyone can help I'd greatly
appreciate it.


"Doesn't work" isn't much to go on, but one thing I wonder about is, what is
the data type of [Structural Sizes].GRADE? You're passing a numeric
(Double) value, according to your function's arguments, but you are putting
single-quotes around the value when you build it into your SQL string.
 

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