How to bound field to control during runtime?

B

bruce

Hi, all:
I have a subform, which RecordSource property is set by VBA. And
then, I want to bound one of recordset's field to a control, but It
sounds wrongly. Here is my code:

lngProblemID = Parent.GetProblemID
strSqlOptions = "SELECT Options.OptID, Options.ProbID,
Options.OptNote, Options.IsRight FROM Options"
strSqlOptions = strSqlOptions & " Where Options.ProbID = " &
lngProblemID
Me.RecordSource = strSqlOptions
Me.Requery


'Add new option record
Set recOptions = Me.Recordset
recOptions.AddNew
recOptions.Fields("ProbID") = lngProblemID


'set action property
With Me!bfrOption1
.ControlSource = "OptNote"
.Requery
.Class = "Word.Document"
.OLETypeAllowed = acOLEEmbedded
.Action = acOLECreateEmbed
End With


"OptNote" is one of Recordset's field,which is ole type. After I did
this, I can edit word in control normally, control's value is allright
indeed, but the recOptions.Fields("Prob") allways holding at Null.
What's the trouble with? Could I do it just like this way. If something

wrong, please wise me up! Thank you.
 
B

Brendan Reynolds

<quote>
strSqlOptions = "SELECT Options.OptID, Options.ProbID,
Options.OptNote, Options.IsRight FROM Options"
</quote>

<quote>
indeed, but the recOptions.Fields("Prob") allways holding at Null.
</quote>

Your SQL statement selects fields named 'OptID', 'ProbID', 'OptNote', and
'IsRight'. It does not select any field named 'Prob'. Possibly that might
have been a typo in the newsgroup post, but if not, if you're trying to do
anything via your form with a field named 'Prob', you'll need to include
that field in the SELECT clause of the SQL statement.
 

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