Good morning,
I am trying to create a code that checks on click if a textbox is empty and if it is it assigns a back colour and makes a textbox(* symbol) visible and then checks if the next textbox and performs the same routine until all have been checked. the end goal being if any are empty the user can clearly see this by means of the back colour change and a * symbol adjacent to the textbox. If all textboxes contain data the record is saved
I realise the way I have attempted to code this is wrong and would appreciate any help as I am stuck at 'End if required'
Thanks
I am trying to create a code that checks on click if a textbox is empty and if it is it assigns a back colour and makes a textbox(* symbol) visible and then checks if the next textbox and performs the same routine until all have been checked. the end goal being if any are empty the user can clearly see this by means of the back colour change and a * symbol adjacent to the textbox. If all textboxes contain data the record is saved
I realise the way I have attempted to code this is wrong and would appreciate any help as I am stuck at 'End if required'
Thanks
Code:
If Me.Location.Value = "" Then
Me.Location.BackColor = RGB(255, 113, 113)
Me.astloc.Visible = True
End If
If Me.cmbMachine.Value = "" Then
Me.cmbMachine.BackColor = RGB(255, 113, 113)
Me.astmachine.Visible = True
End If
If Me.cmbToolType.Value = "" Then
Me.cmbToolType.BackColor = RGB(255, 113, 113)
Me.asttool.Visible = True
End If
If Me.PartNumber.Value = "" Then
Me.PartNumber.BackColor = RGB(255, 113, 113)
Me.astpart.Visible = True
End If
If Me.DrawingNumber.Value = "" Then
Me.DrawingNumber.BackColor = RGB(255, 113, 113)
Me.astdraw.Visible = True
End If
If Me.CALNumber.Value = "" Then
Me.CALNumber.BackColor = RGB(255, 113, 113)
Me.astCAL.Visible = True
End If
If Me.cmbToolCondition.Value = "" Then
Me.cmbToolCondition.BackColor = RGB(255, 113, 113)
Me.asttoolcon.Visible = True
End If
If Me.cmbLine.Value = "" Then
Me.cmbLine.BackColor = RGB(255, 113, 113)
Me.astline.Visible = True
End If
MsgBox "*These fields cannot be blank!"
Else
DoCmd.RunCommand acCmdSaveRecord
MsgBox "Tooling added/edited"