unreferenced control prob

M

mleczko

Hi,

I've got a combobox that I want to check before the user commits the
current record. How do you do it?

I've tried the following and got a combination of runtime errors,
there's gotta be an easier way

If Len(Forms.frmStory.PubCode) <> 2 ... doesn't work
If Forms.frmStory.PubCode = null ...
If Forms.frmStory.PubCode = ""

Help appreciated
Thanks
Nick
 
D

Dirk Goldgar

mleczko said:
Hi,

I've got a combobox that I want to check before the user commits the
current record. How do you do it?

I've tried the following and got a combination of runtime errors,
there's gotta be an easier way

If Len(Forms.frmStory.PubCode) <> 2 ... doesn't work
If Forms.frmStory.PubCode = null ...
If Forms.frmStory.PubCode = ""

Help appreciated
Thanks
Nick

Check how? Check for what? None of those form references is correctly
formed, as there should be a "bang" (!) after the word "Forms", instead
of a "dot" (.). However, Access may be able to figure that part out;
it's pretty clever that way sometimes. There are other problems in your
various tests, though. You might try one of the following:

' check for length not equal 2, allowing for Null
If Len(Forms!frmStory.PubCode & vbNullString) <> 2 Then

' check for Null
If IsNull(Forms!frmStory.PubCode) Then

' check for Null or zero-length string
If Len(Forms!frmStory.PubCode & vbNullString) = 0 Then

' check for zero-length string only
If Forms!frmStory.PubCode = vbNullString Then
 
S

Sarangetti

Dirk,

Yes the bang thing seems optional, it definately works with a dot.

As for the ComboBox, I'll try your suggestions, the point of the
exercise is that the user has to choose something from the box, if not
they get returned to the control

Regards
Nick
 
Top