Solved MS ACCESS VBA: AVOID SPACE AND BLANK CHARACTERS IN NEW ENTRY FORM

georg0307

Registered User.
Local time
Today, 11:54
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,
 
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
 
Hi Spawn or Deadpool (:LOL:),

Thanks for prompt answer I will try.
 
Hi,
I used another way Replace - " " with "" afterupdate Seems work... crossing fingers thanks again
 
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

Back
Top Bottom