Combo box set to null (1 Viewer)

hardik_088

Registered User.
Local time
Yesterday, 21:22
Joined
May 31, 2011
Messages
82
hi guys,
I have form that contain three textbox,combobox and button.
I want that user must have to choose value from combobox or if combobox is empty and you clicked on button you should get message that you must have to choose value from combo box.
so whata i have to do.

i tried this on button click event .but it did,'t work

If (Forms!Form_Name![Combobox_Name].value = null) then
msgbox "You must have to choose value"
End If
----------------And------- this also-----------
If (Forms!Form_Name![Combobox_Name].value = " ") then
msgbox "You must have to choose value"
End If



Thanks a Lot
 

missinglinq

AWF VIP
Local time
Today, 00:22
Joined
Jun 20, 2003
Messages
6,423
The correct syntax in Access VBA would be

IsNull([Combobox_Name])

You can also avoid having to explicitly refer to the form the record is on by using

Me.

and combine your two tests together, testing for Null with Nz(), so that
Code:
If Nz(Me.Combobox_Name,""[B][COLOR="Red"])[/COLOR][/B] = "" Then
 Msgbox "You must have to choose value"
End If
checks for Nulls and Zero Length Strings ("")

Linq ;0)>
 
Last edited:

hardik_088

Registered User.
Local time
Yesterday, 21:22
Joined
May 31, 2011
Messages
82
Thanks dear,
Its work perfectly.
 

hardik_088

Registered User.
Local time
Yesterday, 21:22
Joined
May 31, 2011
Messages
82
oops, when i choose value then it says type mismatch error

thanks,
 

missinglinq

AWF VIP
Local time
Today, 00:22
Joined
Jun 20, 2003
Messages
6,423
Sorry about that! I omitted a closing parens ) on the Nz() function. If you look back at the code I posted I've inserted it and highlighted it in Red.
 

hardik_088

Registered User.
Local time
Yesterday, 21:22
Joined
May 31, 2011
Messages
82
Thanks dear
both ways i have tried and both is working. Great!
nz() function and IsNull([Combobox_Name]).
 

Users who are viewing this thread

Top Bottom