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 / May 2007

Tip: Looking for answers? Try searching our database.

Replace error message

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
acores - 08 May 2007 00:50 GMT
Hello.
I have a table «Customers» linked to a table «Zip Codes». The idea is that
when I enter a zip code in the Customers form, it gives me the respective
city from de «Zip Codes» table.
When I add a new record to the Customers table, and if I close the form
before entering a zip code it gives me an error saying something like «It was
not possible to find a match zip code from the «Zip Code» table» and «The
form cannot be saved this time». I know why this happens: the «Zip Code»
table doesn't have a blank zip code, but my question is:
What is the best way to avoid this error? Or to replace this Access message
to another one more user friendly?
I know that a possible answer to this, is to predefine a valid zip code in
the Customer form field, but is this the only way?
Someone can help me, please?
Thank you in advance.
Best regards.
Carl Rapson - 08 May 2007 16:30 GMT
> Hello.
> I have a table «Customers» linked to a table «Zip Codes». The idea is that
[quoted text clipped - 14 lines]
> Thank you in advance.
> Best regards.

If you've defined a relationship between the two tables based on the zip
code, it may not be possible to save a customer record without a valid zip
code entered (I say "may not" because I don't use the Relationships window
much, so I don't know for sure). What I would suggest is to remove the
relationship (if there is one) and handle it all through code. Use a combo
box on the Customers form to select the zip code, and in the form's Load
event populate the combo box from the Zip Code table (zip code in the first
column and city in the second column). In the AfterUpdate event of the combo
box, reference the second column of the combo box to put the city into the
city field on your form:

me.txtCity = cboZipCodes.Column(1)

If you want to always require a zip code to be entered, then test for it in
the form's BeforeInsert event. You can cancel that event if the zip code
field is empty, which will prevent the record from being inserted (thus not
running afoul of the relationship).

Carl Rapson
 
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.