I have this code in an after update event for a combo box on a form.
But when I put the same code in the load event of the form the txtJobName and txtDescription text boxes do not populate
When the form loads it goes to the last record to see if two table fields are populated before doing anything else. If they are both populated, this code doesn't run, if neither have data, this code doesn't run - but if one field has data and the other does not, then this same code runs in an else if statement.
But when I put the same code in the load event of the form the txtJobName and txtDescription text boxes do not populate
When the form loads it goes to the last record to see if two table fields are populated before doing anything else. If they are both populated, this code doesn't run, if neither have data, this code doesn't run - but if one field has data and the other does not, then this same code runs in an else if statement.
Code:
Private Sub cboShopItemID_AfterUpdate()
Dim db As DAO.Database
Dim rst As DAO.Recordset
Dim shopitem As String
Dim order
Dim SQL As String
shopitem = Me.cboShopItemID
Set db = CurrentDb
SQL = "SELECT [description] FROM qryWorkOrdersShop where WOItems = '" + Me.cboShopItemID + "'"
Set rst = db.OpenRecordset(SQL)
order = Left(shopitem, 5)
Me.txtJobName.Value = DLookup("JobName", "tblOrders", "OrderNumber =" & order)
rst.MoveFirst
Me.txtDescription.Value = rst!Description
rst.Close
Set rst = Nothing
End Sub