Solved MS ACCESS VBA: AVOID SPACE AND BLANK CHARACTERS IN NEW ENTRY FORM (1 Viewer)

georg0307

Registered User.
Local time
Today, 09:28
Joined
Sep 11, 2014
Messages
91
Dear All,

I need to avoid blank / spaces in a Unique ID field in a new record form, I don't know if it is better adopt an After Update code or something So.

Could you please help me on this matter?

Which is the best way to apply this rule?

Thanks,

Best regards,
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 15:28
Joined
May 7, 2009
Messages
19,226
you can use BeforeUpdate event of your Form.

private sub UniqueID_BeforeUpdate(Cancel As Integer)
Cancel = (Len(Trim$(Me!UniqueID & ""))=0)
If Cancel Then
Msgbox "Blank or Spaces not allowed"
End If
end sub
 

georg0307

Registered User.
Local time
Today, 09:28
Joined
Sep 11, 2014
Messages
91
Hi Spawn or Deadpool :)LOL:),

Thanks for prompt answer I will try.
 

georg0307

Registered User.
Local time
Today, 09:28
Joined
Sep 11, 2014
Messages
91
Hi,
I used another way Replace - " " with "" afterupdate Seems work... crossing fingers thanks again
 

jdraw

Super Moderator
Staff member
Local time
Today, 03:28
Joined
Jan 23, 2006
Messages
15,380
As Arnelgp advised--use the BEFOREUpdate event. This event is the last place to change a value before the record is saved. Use the BeforeUpdate event to validate data.
 

Users who are viewing this thread

Top Bottom