Validation Rule for MAC address

  • Thread starter Thread starter tcash283
  • Start date Start date
T

tcash283

Guest
I'm trying to create a working validation rule for a MAC address field in Access 2000 but have been unsuccessful. Does anyone have any ideas?
Thanks for the help !!
 
T,

Roughly, assuming you're going to set up a form to collect the MAC addresses, you might want to create an input mask like this: AA:AA:AA:AA:AA:AA. (You can set up the mask for the control in Form Design mode or for the field in Table Design mode.) Additionally, you can set the form's Key Preview Event to Yes and then use code in the control's KeyPress Event to allow only valid MAC address characters: A-F, 0-9.

(Search on Keypress in this forum or in Access Help if you haven't worked with it before.)

And on the control's Before Update Event, code like this wouldn't hurt.
Code:
Dim strMac As String
strMac = Me.txtBoxControlName.Value

If strMac = "FF:FF:FF:FF:FF:FF" Then
    MsgBox "Invalid. Broadcast address"
	DoCmd.CancelEvent
End If
Lastly, in table design mode, make sure the field that stores the addresses is indexed, with no duplicates allowed.

Regards,
Tim
 

Users who are viewing this thread

Back
Top Bottom