check a value is populated before running code. (1 Viewer)

Geordie2008

Registered User.
Local time
Today, 22:30
Joined
Mar 25, 2008
Messages
177
Hello,

I have a form that filters another form.

I want to ensure that the "txt_Last_Name_from_combo" text box is populated when the user selects the "cmd_Open_Form_Click" and if it is then open the form as usual (I already have the code for this) and if not then msgbox "You must select a user" and cancel opening the form....

can anyone help plz?
 

CrystalSurfer

Matrix activist
Local time
Today, 14:30
Joined
Jan 11, 2006
Messages
75
How about disabling the button to the second form until text is entered in "txt_Last_Name_from_combo"?
That tends to be more user friendly.
To do that you have to put this:
Code:
Me.cmd_Open_Form.Enabled = False
into the OnOpen event of your first form then re-enable it when you there is something entered:

Code:
If Me.txt_Last_Name_from_comboMe is not null then
Me.butOK.Enabled = True
end if
 

Geordie2008

Registered User.
Local time
Today, 22:30
Joined
Mar 25, 2008
Messages
177
Thanks for this, looks like a much neater solution!

I get a debug error on:

If Me.txt_Last_Name_from_comboMe is not null then

I can see that the value is populated when i hover over the code (e.g. it has "John smith" populated) but it comes up with the error:

Run-time error 424. Object required.

Is there anyway to do a check that the length of the value within "txt_Last_Name_from_combo" is >0?

Tnx!
 

Geordie2008

Registered User.
Local time
Today, 22:30
Joined
Mar 25, 2008
Messages
177
ah-ha...

changed to:

If txt_Last_Name_from_combo.Value <> "" Then

and works great!
Many thanks,
Mandy
 

Users who are viewing this thread

Top Bottom