Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Take data of queries for Textbox

Status
Not open for further replies.

danvzla

Programmer
Jan 16, 2004
28
FI
Hi

Lets say that I select a "Text" from a combo box (form1), then I use that text to filter a field on a Query (only one line will result). How can I do to show the value of one of the fields of the resulted query on a textbox(form1)

Also I need to show on a textbox a concatenation (&) of different records that are in other objects of the form, a Table and a query. Now I only can refer to the objects of the form, not to any table or query. It gives me an error "the object doesn't contain the automation object "table" ?????

Thanks!!
 
Tables and queries should NOT be visible at all.
You should work with data through recordsets behind forms.

DAO model:
Dim strSQL As String
strSQL="Select * From TableName Where ConditionField = '" & Me.ComboName & "'"
Set rst = CurrentDb.OpenRecordset(strSQL)
With rst
If .BOF And .EOF Then
Me.TextBoxName = "No match"
Else
Me.TextBoxName = rst.Fields("FieldName")
End If
.Close
End With
Set rst = Nothing

Alternatively you could use DLookup in the controlsource property of the textbox:

= DLookup("FieldToDisplay", "SourceTableName", "[ConditionField] = '" & [ComboName] & "'")

Concatenation-the same thing. You can't use the data in tables or queries, just what's returned in recordsets...

HTH





[pipe]
Daniel Vlas
Systems Consultant

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top