469,306 Members | 2,012 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,306 developers. It's quick & easy.

Textbox help

Sorry if this is a stupid question but ive been struggling with this for a little while now. I am trying to get a text box on a form to display a text value according to which record is selected using a query:

Open the form with appropriate record:

Private Sub butCreateOrder_Click()
Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "frmOrderDetail"

DoCmd.OpenForm stDocName, , , stLinkCriteria
Forms!frmOrderDetail.OrderSupplierid = Me!supplierid
End Sub

Ive tried this in the textbox control source and using vb code with no luck:

SELECT [suppliervendornumber] FROM suppliers WHERE [OrderSupplierid] = suppliers.[supplierid]

Am I close or am i completely off track here??
May 2 '06 #1
1 1316
I'm not sure this will work for you because I'm not sure how you have your form set up, but one solution would be to set the form's Record Source property to the query you built, then select the field you want from the field list and drop it onto the form (if the field list isn't visible, then go to View->Field List).

If your query returns multiple records you'll need to build a way to select or scroll through the records it returns though.

Another method would be to put the query in the textbox control's Row Source property. I use this when I want to populate the textbox based on the value of another control on the form (a dropdown for instance). Once the query has been added to the row source, you'll need to write some code to requery the textbox whenever the control the textbox depends on is changed.
May 2 '06 #2

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

reply views Thread by Jonas L | last post: by
4 posts views Thread by Jurjen de Groot | last post: by
2 posts views Thread by Alex Shirley | last post: by
8 posts views Thread by Filipe Marcelino | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
reply views Thread by harlem98 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.