updating txt boxes with query

dhunter

Registered User.
Local time
Today, 15:13
Joined
Jul 1, 2009
Messages
26
i have one table = tbl_All_SOW

customer = text
sow_num = num
description = text
price = text
billed = yes/no
signed = yes/no
etc

On my form I have two combo boxes. Customer and Sow_num. Once a user has selected a customer the sow combo box only displays the sows for that customer. This should correspond to one row in the table. This part works.

What I need is to update several (about 15) txt boxes or check boxes with the values from the table based upon the users selections. I can't use a subform b/c the users don't like the look =(

here is my code:

Private Sub cbo_Customer_AfterUpdate()
'the value choosen in the customer combo box is stored in the customer textbox.
Me.tbx_Customer.Value = Me.cbo_Customer.Value

'after the customer textbox has been updated the sow combo box will only display the sow's for that customer.
Me.cbo_SOW_Num.RowSource = "SELECT tbl_ALL_SOW.SOW_Num" & _
" FROM tbl_ALL_SOW" & _
" WHERE tbl_ALL_SOW.Customer = '" & Me.tbx_Customer.Value & "'"

End Sub

Private Sub cbo_SOW_Num_AfterUpdate()
'the value choosen in the sow combo box will be stored in the sow textbox.
Me.tbx_SOW_Num.Value = Me.cbo_SOW_Num.Value

'this part should update the description text box, but it doesn't
Me.Description.Value = "SELECT tbl_ALL_SOW.Description " & _
"FROM tbl_ALL_SOW" & _
" WHERE tbl_ALL_SOW.Customer = '" & Me.tbx_Customer.Value & "'" & _
" AND tbl_ALL_SOW.SOW_Num = Me.tbx_SOW_Num.Value"

Everything works except for description. On the form once you have choosen a customer and sow the field displays the select statement. I know this is a syntax issue but knowing little to nothing about vb I have no idea what I am doing wrong. please help!!!!
 
You cannot populate a textbox using a SELECT query in VBA. You'll have to use DLookUp() for this.
 
Great that is a big help thanks!!

However, its not working with check box values. Still playing around with it but do I have to do something else to it to make it tick or untick a check box based upon the values in the table? they are yes/no check boxes in the table.

Thanks again!
 

Users who are viewing this thread

Back
Top Bottom