Code Problem, Control Source Being Deleted on afterupdate

taosd

New member
Local time
Today, 16:33
Joined
Aug 27, 2003
Messages
9
I have a field that when updated populates some fields.

The code for the afterupdate property is as follows

Code:
Private Sub Part_Number_AfterUpdate()
Dim db As DAO.Database
Dim QD As DAO.QueryDef
Dim where As Variant

Set db = CurrentDb()
'Delete the existing dynamic query; trap the error if the query does not exist.
On Error Resume Next
db.QueryDefs.Delete ("Station")
On Error GoTo 0

where = Null

If Left(Me![Part Number], 1) = "*" Or Right(Me![Part Number], 1) = "*" Then
    where = where & " AND [Part Number] Like '" + Me![Part Number] + "'"
Else
    where = where & " AND [Part Number]='" + Me![Part Number] + "'"
End If

Set QD = db.CreateQueryDef("Station", _
      "Select * from [Parts]" & (" where " + Mid(where, 6) & ";"))

'DoCmd.OpenQuery "Station"
Me.sfrmOHMAll.Form.RecordSource = "Station"

End Sub

However, when I add the following code to the end of the code (right before the 'End Sub') it deletes the information in the Part_Number field (where I am inputting data) why does this happen.

evil added deletion code:
Code:
If [Forms]![Entry]![sfrmOHMAll].[Form]![VendName] = "737" Then
Me.ATA__4_.ControlSource = "=Right$(Replace([Forms]![Entry]![sfrmOHMAll].[Form]![ATA],'-',''),8)"
Else
Me.ATA__4_.ControlSource = "=Right$(Replace([Forms]![Entry]![sfrmOHMAll].[Form]![ATA],'-',''),4)"
End If
 

Users who are viewing this thread

Back
Top Bottom