I am running code to copy a record to a new record
Private Sub btnCopy_Click()
Dim ProgramNo As String
Dim PartName As String
Dim DRGno As String
Dim BarType As String
Dim cbomachine As String
Dim Combo129 As String
Dim OperationNumber As String
Dim TxtDRGno1 As String
Dim Jaws As String
Dim ThroughDrillSize As String
Dim BUNG As String
'Copy fields to variables
ProgramNo = Me.[Program No]
PartName = Me.[Part Name]
DRGno = Me.DRGno
BarType = Me.[Bar Type]
cbomachine = Me.cbomachine
Combo129 = Me.Combo129
OperationNumber = Me.[Operation Number]
TxtDRGno1 = Me.TxtDRGno1
Jaws = Me.[Jaws & Chuck Jaw Data]
ThroughDrillSize= Me.[Through Drill Size]
BUNG = Me.BUNG
'Go to a new record
DoCmd.GoToRecord , , acNewRec
'Reverse the process and plug old values into new record
Me.[Program No] = ProgramNo
Me.[Part Name] = PartName
Me.DRGno = DRGno
Me.[Bar Type] = BarType
Me.cbomachine = cbomachine
Me.Combo129 = Combo129
Me.[Operation Number] = OperationNumber
Me.TxtDRGno1 = TxtDRGno1
Me.[Jaws & Chuck Jaw Data] = Jaws
Me.[Through Drill Size] = ThroughDrillSize
Me.BUNG = BUNG
End Sub
It seems that if any of these entries are empty it throws up a debug error for the code on the line that's copying the entry to the string
ie. TxtDRGno1 = Me.TxtDRGno1. if there is an entry, the same code works fine and copies the entry.
My question is can an if statement be added that checks if the entry id blank and doesn't run TxtDRGno1 = Me.TxtDRGno1, but if there is an entry it then runs the code.