Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Forms / July 2007

Tip: Looking for answers? Try searching our database.

Help with combo box behaviour

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
winsa - 27 Jun 2007 06:08 GMT
Hi

Using A2K3, SQL backend.

I have a bound combo box displaying 2 columns (of a possible 5).  
LimitToList is set to Yes.

I am using the following test in the Click event of a Save&Close button on
the form:  If Len(Me.Debtor & VbNullString) = 0 Then Msgbox "Error"

This works if I haven't touched the combo box at all when filling in the
form, the error message will fire.  However, if I select a Debtor, tab off or
leave the combo box, go back and delete the entry using the backspace key,
the error message will not fire when the Save&Close button is clicked.  
Access seems to bypass the error message and tries to save, which it
obviously can't because Debtor is a required field, and thereby throws up the
INSERT fails error.

To me it looks like an empty combo box as I thought I had deleted all the
text.  However, I have noticed that whenever I go back to the combo box,
there seems to be an entry of 5 spaces?!?  I have tried testing this in the
NotInList event, but that event doesn't seem to fire.  I have also tried
testing in the BeforeUpdate event too, but same result, ie. nothing!

Can anybody explain why this is happening and/or how I can then test whether
or not this field is null/empty before continuing?

Any help would be greatly appreciated.

Signature

Regards
Winsa

SteveM - 27 Jun 2007 12:02 GMT
Try this instead:
If Nz(Me.Debtor, "") = "" Then Msgbox "Error"

Steve

> Hi
>
[quoted text clipped - 24 lines]
>
> Any help would be greatly appreciated.
winsa - 03 Jul 2007 00:28 GMT
Hi Steve

Thanks for your suggestion.  Sorry for not getting back to you, as I have
been off from work for a while.

The suggested use of Nz didn't work.  Only worked when I entered the five
spaces, but then it's not testing for an empty field any longer.

Any other suggestions?

Signature

Regards
Winsa

> Try this instead:
> If Nz(Me.Debtor, "") = "" Then Msgbox "Error"
[quoted text clipped - 29 lines]
> >
> > Any help would be greatly appreciated.
Bob Quintal - 03 Jul 2007 13:14 GMT
> Hi Steve
>
[quoted text clipped - 6 lines]
>
> Any other suggestions?

try  If Len(Trim(Me.Debtor) & VbNullString) = 0 Then Msgbox
"Error"

Signature

Bob Quintal

PA is y I've altered my email address.

--
Posted via a free Usenet account from http://www.teranews.com

winsa - 04 Jul 2007 00:40 GMT
Excellent!!  The TRIM function worked like a charm!!  I'm still getting those
weird five spaces if I delete the entry in the combo box, but the error is
firing correctly.

Thanks so much Bob!  You're a star!

Signature

Regards
Winsa

> > Hi Steve
> >
[quoted text clipped - 9 lines]
> try  If Len(Trim(Me.Debtor) & VbNullString) = 0 Then Msgbox
> "Error"
Bob Quintal - 04 Jul 2007 03:09 GMT
> Excellent!!  The TRIM function worked like a charm!!  I'm
> still getting those weird five spaces if I delete the entry in
> the combo box, but the error is firing correctly.
>
> Thanks so much Bob!  You're a star!

/me blushes.

Thank you.

In the last few days I've been called a genius, a god and now a
star. If only my boss would call me something other than
"Troublemaker"

Signature

Bob Quintal

PA is y I've altered my email address.

--
Posted via a free Usenet account from http://www.teranews.com

 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.