Hi there,
I have a form that has a textbox called "S1_SN" and I have a query called Qry_AutoPop that works and generates the required information. One of the fields in the query is also called "S1_SN". The query is initiated based on the "Bath_SN" value. The form also has this field. Both form and query take their information from the same source- TblDocuments.
What I would like to have happen is a button on the form that when pressed, runs Qry_AutoPop, copies the result/value from the field "S1_SN" and pastes that value into the form textbox called "S1_SN", using the "Bath_SN" value in the form as the input data source for the query.
I have been trying to use the following code:
I cannot set the record source of the textbox as the query because I want this to be an optional action the user can perform if they choose to, but can also ignore it as well. There is a reason for this, based on the end user's working practices, essentially meaning that sometimes, textbox "S1_SN" will be new data, and on other occasions, it will be the same data as a previous records based on the "Bath_SN" field.
Currently, the above code doesn't throw up an error, it just does nothing at all after the button is pressed.
Any help would be greatly appreciated.
I have a form that has a textbox called "S1_SN" and I have a query called Qry_AutoPop that works and generates the required information. One of the fields in the query is also called "S1_SN". The query is initiated based on the "Bath_SN" value. The form also has this field. Both form and query take their information from the same source- TblDocuments.
What I would like to have happen is a button on the form that when pressed, runs Qry_AutoPop, copies the result/value from the field "S1_SN" and pastes that value into the form textbox called "S1_SN", using the "Bath_SN" value in the form as the input data source for the query.
I have been trying to use the following code:
Code:
Me.S1_SN = DLookup("S1_SN", "Qry_AutoPop", "[Bath_SN] = '" & Me.Bath_SN & "'")
I cannot set the record source of the textbox as the query because I want this to be an optional action the user can perform if they choose to, but can also ignore it as well. There is a reason for this, based on the end user's working practices, essentially meaning that sometimes, textbox "S1_SN" will be new data, and on other occasions, it will be the same data as a previous records based on the "Bath_SN" field.
Currently, the above code doesn't throw up an error, it just does nothing at all after the button is pressed.
Any help would be greatly appreciated.