My intent with the code below is to copy the Me.Serial value into the hostname, than check the Me.Serial value and if it begins with PDS, strip that off and write the new number as Me.Serial.
What happens is I get two record sets in my table - one that has no Me.Serial and the hostname, the other has the stripped Me.Serial and no hostname.
What happens is I get two record sets in my table - one that has no Me.Serial and the hostname, the other has the stripped Me.Serial and no hostname.
Code:
Private Sub Serial_AfterUpdate()
Dim MyDB As Database
Dim hostname As String
Set MyDB = CurrentDb
hostname = Me.Serial
If Me.Serial Like "PDS*" Then
Me.Serial = Right(Me.Serial, Len(Me.Serial) - 3)
DoCmd.SetWarnings False
DoCmd.RunSQL "INSERT INTO tblTemp (tmptoHostname) VALUES ('" & hostname & "')"
DoCmd.SetWarnings True
End If
End Sub