Text Box and Memo field

B

Brian

Hi All,
I would appreciate any help in this matter.

I'm trying to set up a recipe db for an elderly granny.

Table Fields
RecID (PK), RecType, RecIngr, RecName, Recipe

I have a form with two cbos, cbo01Typ and cbo02Ing, that supply the
criteria, Type, Ingredient, for a query, QryRec01.

I have a third cbox, cbo03RecNam, that recieves the results of the query,
RecID and RecName.

I have a text box, txb04Rec, that I would like to display the Recipe in.

I have tried putting the recipe in the cbo03RecNam as a hidden column, but
it seems to have a text limit.

I have tried to set the RecordSource of the txtb to the Recipe field of Q1,
with no luck.

Since I have the RecID available in the cbo03RecNam, how can I use this to
display the Recipe in the textbox?

Brian
 
P

peter walker

Private Sub cbo03RecNam_AfterUpdate()
'///////////////////////////////////
'We use a recordset to retrieve the memo
'column data as display that in a text box.
'The SQL used returns the record based on the
'numeric surrogate key 'RecID'
'We test for nulls because the operator may
'backspace out text in the cbo resulting in
'a null being passed in the SQL. I also use
'the NZ because to fend off some wierd
'situation in future versions (whatever) where
'it may be possible to read a empty string.
'///////////////////////////////////

Dim rst As DAO.Recordset
Dim db As DAO.Database
Set db = CurrentDb()

If Nz(Me.cbo03RecNam, "") <> "" Then
Set rst = db.OpenRecordset _
( _
"SELECT Recipe " & _
"FROM Recipes " & _
"WHERE RecID = " & cbo03RecNam _
)
'If we have indeed have data
If Not (rst.EOF And rst.BOF) Then
Recipe = rst!Recipe
End If ' (EOF / BOF test)
End If ' (Null / empty test)
End Sub


See
www.papwalker.com/public/recipehelp.mdb
--

peter walker MVP

Please post replies to the news group so everyone can benefit.
www.papwalker.com
 
B

Brian

Thank you Peter, I'll give this a try.
Brian

peter walker said:
Private Sub cbo03RecNam_AfterUpdate()
'///////////////////////////////////
'We use a recordset to retrieve the memo
'column data as display that in a text box.
'The SQL used returns the record based on the
'numeric surrogate key 'RecID'
'We test for nulls because the operator may
'backspace out text in the cbo resulting in
'a null being passed in the SQL. I also use
'the NZ because to fend off some wierd
'situation in future versions (whatever) where
'it may be possible to read a empty string.
'///////////////////////////////////

Dim rst As DAO.Recordset
Dim db As DAO.Database
Set db = CurrentDb()

If Nz(Me.cbo03RecNam, "") <> "" Then
Set rst = db.OpenRecordset _
( _
"SELECT Recipe " & _
"FROM Recipes " & _
"WHERE RecID = " & cbo03RecNam _
)
'If we have indeed have data
If Not (rst.EOF And rst.BOF) Then
Recipe = rst!Recipe
End If ' (EOF / BOF test)
End If ' (Null / empty test)
End Sub


See
www.papwalker.com/public/recipehelp.mdb
--

peter walker MVP

Please post replies to the news group so everyone can benefit.
www.papwalker.com
 

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